none
Problem with My Kinect SkeletalView plug in (move a point with arrows keys)) RRS feed

  • Question

  •  

    Hello, I'm changing the design SkeletalView, the MicrosoftSDK sample.

    Basically I have to:

    1) create a volume (a virtual room) where the skeleton has to be drawn inside, while outside should not be drawn.
    No changes in the design of the skeleton, just overlay the screen that obscureareas of the skeleton in the case, the sckeleton go outside of the room.

    2) show the X, Y, Z point of the head

    3) two additional windows where you see only head point that follow the movement of the head point of skeleton (top view and front view)

    4) draw a point in the up window and in the frontal window that I can move with arrow keys (move only inside up window is sufficient)

    I have any problem to join the X and Y coord., Z is calculating by using Y and Xof my own system of coordinates.
    What I can not do is display any point (the point of the head in particular) in the two windows.

    How can I send you the solution for visual studio that I changed??

    Tanks and sorry for my english.





    • Edited by losscasa Thursday, August 11, 2011 3:55 PM
    Monday, August 8, 2011 6:22 PM

Answers

  • OK, I've downloaded and compiled your files, and so far there are a couple of problems:

    1) Nui_DrawPoint is never called by anyone. I set a breakpoint at the beginning, and it's never hit. So, your code is never executed.

    2) I don't see the updated code you pasted above in your NuiImpl.cpp function. Maybe different versions? In any case, You put the MoveToEx and LineTo functions in a random place. You have to do the drawing code after you have called SelectObject(hdc,hJointPen) and before you've called SelectObject(hdc,hOldObj)

    Eddy

     


    I'm here to help
    Thursday, August 11, 2011 1:10 AM
  • NOW IT WORK!!!

    this is my final function:

     

    void CSkeletalViewerApp::Nui_DrawPoint( bool bBlank, HWND hWnd)

     {

    // WHITENESS

    HDC hdc = GetDC( hWnd );

        RECT rct;

        GetClientRect(hWnd, &rct);

        int width = rct.right;

        int height = rct.bottom;

    if(bBlank)

    {

    PatBlt( hdc, 0, 0, width, height, WHITENESS );

    }

    HPEN hJointPen;

    hJointPen = CreatePen(PS_SOLID,9, RGB(0, 0, 255));

    HGDIOBJ hOldObj = SelectObject(hdc,hJointPen);

    MoveToEx( hdc, 50, 50, NULL );

    LineTo( hdc, 50, 50);

    SelectObject( hdc, hOldObj );

        DeleteObject(hJointPen);

    // CREATE A LINE! YES (work)

     

    return;

    }// END METODO

     

    Tanks!!!

     

    now I should move this point with arrows key!

    http://social.msdn.microsoft.com/Forums/en-US/kinectsdknuiapi/thread/46ebc6d6-9813-4ade-a174-87d629eec5a0/


    loss
    • Marked as answer by losscasa Sunday, August 14, 2011 12:31 PM
    Thursday, August 11, 2011 9:35 AM

All replies

  • If you want to send the whole solution to look at, you could upload it to codeples (http://www.codeplex.com/) or maybe share it through dropbox (www.dropbox.com), or some other free solution. Whichever is most convenient to you.

    As far a generic advice before seeing code, the SkeletalViewer sample, and your code based on it does seem to be able to draw points and lines just fine in the window with control ID equal to IDC_SKELETALVIEW (see skeletalviewer.rc). Did you try to replicate the drawing code for this skeleton, or does that basic drawing pattern using a DirectX surface not appropriate for the other two drawing scenarios you have?

    Eddy


    I'm here to help
    Tuesday, August 9, 2011 10:54 PM
  • hello, yes I've tried to replicate the code but I'm not very experienced yet.

    I put the solution inside Dropbox directory CPP in public folders (my email is losscasa@yahoo.it).
    Do not watch the second project called "coord", is just a test that does not compile.

    If you help me you're welkome

    I am disperate beginner


    Can you see it in myDropbox public folder?
    Tuesday, August 9, 2011 11:17 PM
  • THIS IS MY PRIMITIVE FUNCTION INSIDE NuiImpl()

     

    void CSkeletalViewerApp::Nui_DrawPoint( bool bBlank, HWND hWnd)
     {
    	//	WHITENESS
    	HDC hdc = GetDC( hWnd );
      RECT rct;
      GetClientRect(hWnd, &rct);
      int width = rct.right;
      int height = rct.bottom;
    	PatBlt( hdc, 0, 0, width, height, WHITENESS );
      ReleaseDC( hWnd, hdc );
    	//	WHITENESS (work)
    
    
    	//	DON'T WORK
    	POINT test;
    	
    	HPEN hJointPen;
        
      hJointPen = CreatePen(PS_SOLID,9, RGB(0, 0, 255));
    	HGDIOBJ hOldObj=SelectObject(m_PointDC,hJointPen);
    
    	m_MyPoint = CreatePen( PS_SOLID,9, RGB(0, 0, 255) );
    
    	m_MyPoints[1].x = 50;
    	m_MyPoints[1].y = 50;
    	
    	hOldObj=SelectObject(m_PointDC,m_MyPoint);
    
    	if( bBlank )
      {
        PatBlt( m_SkeletonDC, 0, 0, width, height, BLACKNESS );
      }
    
      int scaleX = width; //scaling up to image coordinates
      int scaleY = height;
      float fx=0,fy=0;
      //int i;
      /*for (i = 0; i < NUI_SKELETON_POSITION_COUNT; i++)
      {
        NuiTransformSkeletonToDepthImageF( pSkel->SkeletonPositions[i], &fx, &fy );
        m_Points[i].x = (int) ( fx * scaleX + 0.5f );
        m_Points[i].y = (int) ( fy * scaleY + 0.5f );
      }
    	*/
      //SelectObject(m_PointDC,m_Pen[PointColor%m_PensTotal]);
      
      //Nui_DrawSkeletonSegment(pSkel,4,NUI_SKELETON_POSITION_HIP_CENTER, NUI_SKELETON_POSITION_SPINE, NUI_SKELETON_POSITION_SHOULDER_CENTER, NUI_SKELETON_POSITION_HEAD);
      
      
      // Draw the joints in a different color
      /*for (i = 0; i < NUI_SKELETON_POSITION_COUNT ; i++)
      {
        HPEN hJointPen;
        
        hJointPen=CreatePen(PS_SOLID,9, g_JointColorTable[i]);
        hOldObj=SelectObject(m_SkeletonDC,hJointPen);
    
        MoveToEx( m_SkeletonDC, m_Points[i].x, m_Points[i].y, NULL );
        LineTo( m_SkeletonDC, m_Points[i].x, m_Points[i].y );
    
        SelectObject( m_SkeletonDC, hOldObj );
        DeleteObject(hJointPen);
      }
    	*/
      return;
    }// END METODO
    



    loss
    Wednesday, August 10, 2011 12:07 PM
  • I see a couple of potential issues:
     
    1) That code snippet above does not actually issue any drawing commands. You just create a pen and then select it into the device context (m_PointDC). To draw a point at coordinates (50,50), you need to do something like
     
    MoveToEx( m_PointDC, 50, 50, NULL );
    LineTo( m_PointDC, 50, 50);
    after selecting the pen.
    2) I'm not sure if this is an issue, but the code that uses PatBlt and works uses hdc and the code that doesn't work uses m_PointDC. If suggestion 1) above still doesn't work, try using the same device context for both operations, or check your initialization of m_PointDC to see why it might not be working.
    Also, I can't find your public folder from the information you gave me. If you want me to look at your code, right click on a file, select "Copy public link" and let me know what that link is so I can look at it.
    Eddy

    I'm here to help
    Wednesday, August 10, 2011 6:51 PM
  • NOW YOU CAN DOWNLOAD MY FILES. TANKS

     

    http://dl.dropbox.com/u/8129274/Cpp/DrawDevice.cpp

     

    http://dl.dropbox.com/u/8129274/Cpp/NuiImpl.cpp

     

    http://dl.dropbox.com/u/8129274/Cpp/SkeletalViewer.sln SOLUTION

     

    http://dl.dropbox.com/u/8129274/Cpp/SkeletalViewer.h

     

    http://dl.dropbox.com/u/8129274/Cpp/SkeletalViewer.cpp

     

    http://dl.dropbox.com/u/8129274/Cpp/SkeletalViewer.rc

     

    http://dl.dropbox.com/u/8129274/Cpp/resource.h


    loss
    Wednesday, August 10, 2011 9:58 PM
  • You say like this??? it don't work again :(
    void CSkeletalViewerApp::Nui_DrawPoint( bool bBlank, HWND hWnd)
     {
    // WHITENESS
    HDC hdc = GetDC( hWnd );
        RECT rct;
        GetClientRect(hWnd, &rct);
        int width = rct.right;
        int height = rct.bottom;
    PatBlt( hdc, 0, 0, width, height, WHITENESS );
    // WHITENESS (work)
    MoveToEx( hdc, 50, 50, NULL );
    LineTo( hdc, 50, 50);
    HPEN hJointPen;
        hJointPen = CreatePen(PS_SOLID,9, RGB(0, 0, 255));
        //hJointPen=CreatePen(PS_SOLID,9, g_MyJointColorTable[1]);
    HGDIOBJ hOldObj = SelectObject(hdc,hJointPen);
        SelectObject( hdc, hOldObj );
        DeleteObject(hJointPen);
        ReleaseDC( hWnd, hdc );
    // WHITENESS (work)
        return;
    }// END METODO

    loss
    Wednesday, August 10, 2011 10:19 PM
  • OK, I've downloaded and compiled your files, and so far there are a couple of problems:

    1) Nui_DrawPoint is never called by anyone. I set a breakpoint at the beginning, and it's never hit. So, your code is never executed.

    2) I don't see the updated code you pasted above in your NuiImpl.cpp function. Maybe different versions? In any case, You put the MoveToEx and LineTo functions in a random place. You have to do the drawing code after you have called SelectObject(hdc,hJointPen) and before you've called SelectObject(hdc,hOldObj)

    Eddy

     


    I'm here to help
    Thursday, August 11, 2011 1:10 AM
  • NOW IT WORK!!!

    this is my final function:

     

    void CSkeletalViewerApp::Nui_DrawPoint( bool bBlank, HWND hWnd)

     {

    // WHITENESS

    HDC hdc = GetDC( hWnd );

        RECT rct;

        GetClientRect(hWnd, &rct);

        int width = rct.right;

        int height = rct.bottom;

    if(bBlank)

    {

    PatBlt( hdc, 0, 0, width, height, WHITENESS );

    }

    HPEN hJointPen;

    hJointPen = CreatePen(PS_SOLID,9, RGB(0, 0, 255));

    HGDIOBJ hOldObj = SelectObject(hdc,hJointPen);

    MoveToEx( hdc, 50, 50, NULL );

    LineTo( hdc, 50, 50);

    SelectObject( hdc, hOldObj );

        DeleteObject(hJointPen);

    // CREATE A LINE! YES (work)

     

    return;

    }// END METODO

     

    Tanks!!!

     

    now I should move this point with arrows key!

    http://social.msdn.microsoft.com/Forums/en-US/kinectsdknuiapi/thread/46ebc6d6-9813-4ade-a174-87d629eec5a0/


    loss
    • Marked as answer by losscasa Sunday, August 14, 2011 12:31 PM
    Thursday, August 11, 2011 9:35 AM
  • EDDY, I'LL UPDATE MY NEW FILES IN DROPBOX!

     

     

    Hi, this is my new file that you can download:

     

    http://dl.dropbox.com/u/8129274/Cpp/NuiImpl.cpp

    http://dl.dropbox.com/u/8129274/Cpp/SkeletalViewer.cpp

    http://dl.dropbox.com/u/8129274/Cpp/SkeletalViewer.h

    http://dl.dropbox.com/u/8129274/Cpp/resource.h

    http://dl.dropbox.com/u/8129274/Cpp/SkeletalViewer.sln

     

    If you see i have one blue point. I have to move blue point with keyboard arrows

     


    loss

    Thursday, August 11, 2011 9:35 AM
  • Great, glad I could help!

    Eddy


    I'm here to help
    Thursday, August 11, 2011 11:00 PM