Spout for Realsense camera

Home Forums Spout Developer Spout for Realsense camera

This topic contains 9 replies, has 2 voices, and was last updated by  leadedge 11 months, 3 weeks ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #2775

    originaltomato
    Participant

    Hello,

    I am using the intel realsense camera console sample in c++ that shows different video feeds from the camera. I wan’t to use it to pass-through the IR stream to spoutcam. But when i use the following code:

    if (spoutsender == NULL) {
    
    			glEnable(GL_DEPTH_TEST);							// enable depth comparisons and update the depth buffer
    			glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations
    
    			spoutsender = new SpoutSender;			// Create a Spout sender object
    			bInitialized = false;		        // Spout sender initialization
    			strcpy(sendername, "IR");	// Set the sender name
    		}
    
    		if (!bInitialized) {
    			bInitialized = spoutsender->CreateSender(sendername, 640, 480); // Create the sender
    			InitGLtexture(sendertexture, 640, 480);
    		}

    i get a warning cannot get gl context

    im using win10 and laptop with intel hd 4000. Diagnostics says everything is compatible.

    The sender demo app only works when i checkbox the the checkbox in spoutdirectx.exe

    Any help is appreciated , thank you for great software!

    #2776

    originaltomato
    Participant

    maybe this helps:

    WGL_NV_DX_interop: OK
    ——————
    wglDXCloseDeviceNV: OK
    wglDXLockObjectsNV: OK
    wglDXObjectAccessNV: OK
    wglDXOpenDeviceNV: OK
    wglDXRegisterObjectNV: OK
    wglDXSetResourceShareHandleNV: OK
    wglDXUnlockObjectsNV: OK
    wglDXUnregisterObjectNV: OK

    WGL_NV_DX_interop2: MISSING

    #2777

    leadedge
    Keymaster

    I am not sure of the rest of the code, but the first thing I would check is whether there is an OpenGL context with wglGetCurrentContext() i.e.

    if(wglGetCurrentContext() == NULL) {
    // no context
    }

    There is an undocumented and untested function in the Spout SDK that should create an invisible OpenGL window and context :

    sender->spout.interop.InitOpenGL();
    and on program exit
    sender->spout.interop.CloseOpenGL();

    If WGL_NV_DX_interop2 is not supported the DirectX 11 functions will not work, but DX9 should be OK.

    #2779

    originaltomato
    Participant

    Hi .. Thank you so much for answering. Yes, you are in the right direction I just managed couple of minutes ago to understand i need a window. I opened one with glut and have context now and I am sending data (read your useful comments in the Spout SDK)

    I might try later to upgrade to windowsless mode

    now I am stuck with converting data.. but that I will have to solve myself 🙂

    I’m not very good with c++ and quite rusty with opengl 🙂

    managed to copy the data into a struct sample->ir->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::PIXEL_FORMAT_RGB32, &data);

    and trying now something like this: gluBuild2DMipmaps(GL_TEXTURE_2D, 1, 640, 480, GL_RGB, GL_UNSIGNED_BYTE, data.planes[0]);

    I’ll keep you updated .. maybe you can use the info for another sample or something

    #2782

    originaltomato
    Participant

    Ok I’m kinda stuck on this one with my knowledge. Does Spout / Opengl use STRIDE in images?

    This is my current status.

    spout and realsense

    Using this code:

    			PXCImage::ImageData data;
    			const PXCCapture::Sample *sample = pp->QuerySample();
    			// Access to the image data in the RGB32 format.
    			sample->ir->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::PIXEL_FORMAT_RGB24, &data);
    			
    			if (bInitialized) {
    				// Grab the screen into the local spout texture
    				glBindTexture(GL_TEXTURE_2D, sendertexture);
    				gluBuild2DMipmaps(GL_TEXTURE_2D, 1, width, height, GL_RGB, GL_UNSIGNED_BYTE, data.planes[0]);
    				glBindTexture(GL_TEXTURE_2D, 0);
    				
    				// Send the texture out for all receivers to use
    				spoutsender->SendTexture(sendertexture, GL_TEXTURE_2D, width, height);
    			}
    #2784

    leadedge
    Keymaster

    Assuming that data.planes[0] has RGB pixels and the total size is width*height*3, you might try :

    glBindTexture(GL_TEXTURE_2D, sendertexture);
    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid *)data.planes[0]);
    glBindTexture(GL_TEXTURE_2D, 0);

    But instead of creating a texture, you might also be able to use SendImage if you update to the latest Spout SDK source on GitHub.

    spoutsender->SendImage((const unsigned char*)data.planes[0], width, height, GL_RGB, true);

    Then the Spout SDK will create a texture internally for you.

    “true” is to invert the image if you find it comes out upside down, otherwise leave it out.

    I looked at supporting stride but it became too complicated. The Spout SDK uses “glPixelStorei(GL_UNPACK_ALIGNMENT, 1)” to deal with RGB pixels, but there is no provision for padding on each line.

    #2786

    originaltomato
    Participant

    Great job! , SendImage works and solves all.. IR is supported not from Realsense to Spout. Its crappy code , but if you want it I can share easily 🙂

    #2787

    leadedge
    Keymaster

    A good result then.

    One valuable thing you have shown is that Intel HD 4000 works fine as long as it is using DirectX 9 because WGL_NV_DX_interop2 is not supported.

    I am sure that your project would be of interest to other people. I am interested in the application and how it develops. Maybe one way is to include it in the next Spout manual which is being finalised now. This could include a link to your website, which might describe the project briefly, where people could email you.

    #3609

    originaltomato
    Participant

    Hello I am so sorry I never saw you wrote here. I am open to help. To start with, this is me: vladimirmitrovic.com .. i managed to use kinect2 -> directx raw stream to Spout webcam -> CCV ( http://ccv.nuigroup.com/#home )

    of course it would have been even better if I wrote a CCV plugin for receiving a spout stream as well.

    im just starting a new project with an intel realsense.. and I might use similar technique

    #3610

    leadedge
    Keymaster

    No problems. It’s good to hear of your successful project. People would be keen to see your work I am sure, so thanks for posting your web page link here. With the Kinect being discontinued I think your new project with the RealSense could be very interesting for those using the Kinect and Spout.

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.