OSX

76 views
Skip to first unread message

Dave

unread,
Nov 11, 2010, 12:42:27 AM11/11/10
to OpenKinect
Has anyone got this to work with OSX yet? I'm having some trouble with
the libusb.

Tim Hawkins

unread,
Nov 11, 2010, 12:48:43 AM11/11/10
to openk...@googlegroups.com
Check out MacPorts

that has libusb as an installable port

Vitor Calejuri

unread,
Nov 11, 2010, 12:52:03 AM11/11/10
to openk...@googlegroups.com

Kyle Machulis

unread,
Nov 11, 2010, 1:32:07 AM11/11/10
to openk...@googlegroups.com
Yeah. iso transfers are stalling on mac. This is usually an issue when developing mac libusb stuff, what works on linux requires some tweaking in OS X. Things may need to align on weird boundaries, etc...

Kyle Machulis

unread,
Nov 11, 2010, 2:54:53 AM11/11/10
to openk...@googlegroups.com
The error seen in the USB prober:

1037.409 [3] AppleUSBEHCI[0x718b800]::CreateHSIsochTransfer Isoch -- incomplete final TD in transfer, command->GetNumFrames() is 1, pEP->Interval is 1 and so transfersPerTD is 8

Reference seen on apple list:


However, this might just be worth waiting until the macam people have this implemented in the actual platform API instead of trying libusb.

Theodore Watson

unread,
Nov 11, 2010, 7:05:25 AM11/11/10
to openk...@googlegroups.com
I've been working on it in macam and had some issues filling the buffers ( initialisation works fine ). 

The glview app also runs but having the same issue with the libusb_submit_transfer failing. 

This also seems related to the iso transfers:

Theo

Hector Martin

unread,
Nov 11, 2010, 9:09:56 AM11/11/10
to openk...@googlegroups.com
Hmm, have you tried the latest code from git? I made the isochronous
transfers use 16 frames per transfer, that might help.

On 11/11/2010 08:54 AM, Kyle Machulis wrote:
> The error seen in the USB prober:
>
> 1037.409 [3]AppleUSBEHCI[0x718b800]::CreateHSIsochTransfer Isoch --
> incomplete final TD in transfer, command->GetNumFrames() is 1,
> pEP->Interval is 1 and so transfersPerTD is 8
>
> Reference seen on apple list:
>
> http://lists.apple.com/archives/usb/2010/Jun/msg00010.html
>
> However, this might just be worth waiting until the macam people have
> this implemented in the actual platform API instead of trying libusb.
>
> On Wed, Nov 10, 2010 at 10:32 PM, Kyle Machulis <ky...@nonpolynomial.com
> <mailto:ky...@nonpolynomial.com>> wrote:
>
> Yeah. iso transfers are stalling on mac. This is usually an issue
> when developing mac libusb stuff, what works on linux requires some
> tweaking in OS X. Things may need to align on weird boundaries, etc...
>
>
> On Wed, Nov 10, 2010 at 9:52 PM, Vitor Calejuri
> <ondeosfrang...@gmail.com

> <mailto:ondeosfrang...@gmail.com>> wrote:
>
> This may also help you debugging:
>
> http://developer.apple.com/hardwaredrivers/download/usbdebug.html
>
> On Thu, Nov 11, 2010 at 3:48 AM, Tim Hawkins <tim.h...@me.com
> <mailto:tim.h...@me.com>> wrote:
>
> Check out MacPorts
>
> that has libusb as an installable port
>
>
> On Nov 11, 2010, at 1:42 PM, Dave wrote:
>
> > Has anyone got this to work with OSX yet? I'm having some
> trouble with
> > the libusb.
>
>
>
>


--
Hector Martin (hec...@marcansoft.com)
Public Key: http://www.marcansoft.com/marcan.asc

Theodore Watson

unread,
Nov 11, 2010, 9:17:11 AM11/11/10
to openk...@googlegroups.com
will try it now thanks!

after tons of usb debugging I found on osx I needed to add:

libusb_claim_interface(dev, 0);

underneath:

dev = libusb_open_device_with_vid_pid(NULL, 0x45e, 0x2ae);
if (!dev) {
printf("Could not open device\n");
return 1;
}


now I am getting transfer errors but the endpoint is found ( before the endpoints weren't found ).

Hector Martin

unread,
Nov 11, 2010, 9:44:48 AM11/11/10
to openk...@googlegroups.com
Ah, very true. I totally forgot to claim the interface, that's certainly
a bug. I'll fix it as soon as I get a rest from all this silly media
attention :)

Theodore Watson

unread,
Nov 11, 2010, 10:00:19 AM11/11/10
to openk...@googlegroups.com
Hey - so I got a first grab in OSX - but as you can see the image is a little jumbled:
http://img6.glowfoto.com/images/2010/11/11-0647332562L.png

only getting the first frame then rgb_callback stops getting called.

I had to change a few other things:
#define PKTS_PER_XFER 32
#define NUM_XFERS 512

uint8_t rgb_frame[640*480*4]; <-- changed to *4 as bayer to RGB was going out of bounds.

and in depth_process

if (hdr->flag != 0x75){
return
}

to

if (hdr->flag != 0x75 && hdr->flag != 0x72){
return;
}


and in rgb_process

if (hdr->flag != 0x85){
return;
}

to

if (hdr->flag != 0x85 && hdr->flag != 0x82){
printf("hdr->flag is %02x\n", hdr->flag);
return;
}


Also I have been hacking at libusb on OS X and for some reason my hacked version works but the offical one doesn't.
Have to figure out what it is :)

Hector Martin

unread,
Nov 11, 2010, 11:10:36 AM11/11/10
to openk...@googlegroups.com
That looks like entirely caused by packet loss (keep in mind that the
kinect uses >20MB/s of bandwidth, you need pretty efficient software to
keep up). The overflow isn't because of bayer to RGB (the bayer image is
640*480 bytes), it's because it misses "frame end" flags and overflow
the buffer (this will be fixed once I add better logic to interpret the
packet numbers).

Good job on getting it to work on OSX though!

Theodore Watson

unread,
Nov 11, 2010, 11:49:18 AM11/11/10
to openk...@googlegroups.com
Hey guys - here it is running on OS X:
http://vimeo.com/16734124

The source code is included in the video link and so is the libusb which you won't need to install.

The results I ended up using were:
#define DEPTH_LEN 2048
#define RGB_LEN 2048

#define PKTS_PER_XFER 512
#define NUM_XFERS 1

Anything else would results in the buffers coming in out of order.

There aren't too many mods - the most important being libusb_claim_interface
The code is a little different right now as it has tons of my debugging efforts littered though it.

Huge thanks Hector for all the help and for making the library!!

> That looks like entirely caused by packet loss (keep in mind that the
> kinect uses >20MB/s of bandwidth, you need pretty efficient software to
> keep up).

Yeah I noticed even having printfs in the callbacks caused a visible difference in the results.

Hector Martin

unread,
Nov 11, 2010, 12:01:09 PM11/11/10
to openk...@googlegroups.com
Looks like you traded off packet loss for frame loss, by making your
transfer large and using only one. The framerate is supposed to be very
high, 30fps.

1 transfer is generally a bad idea, because it means any packets coming
in while those 512 packets are processed are inevitably lost. Have you
tried something like 4 transfers of 512 packets? Or maybe 8 transfers of
128 packets or similar.

The length shouldn't matter as long as it's large enough, but maybe the
2K alignment helps, so that's good.

Theodore Watson

unread,
Nov 11, 2010, 12:28:50 PM11/11/10
to openk...@googlegroups.com
hey thanks!!

#define PKTS_PER_XFER 128
#define NUM_XFERS 8

gives much faster results

MikeManh

unread,
Nov 18, 2010, 11:22:04 AM11/18/10
to OpenKinect
So did everybody here use the macports instead of pulling the git repo
for libusb? I'm having some problems and I'd like to follow whatever
path other people used in getting libusb.
The instructions on the github page for libfreenect say:

> > You will need to pull the libusb-1.0 repo head and patch using the files in platform/osx/. Just go to the root directory of the cloned libusb-1.0 repo and run

> > patch -p1 < [path_to_OpenKinectRepo]/platform/osx/libusb-osx-kinect.diff

I tried pulling the git repo for libusb from git://git.libusb.org/libusb.git
but there was no configure script, and my attempts to run autotools
failed. I ended up downloading libusb-1.0.7.tar.bz2 from (http://
sourceforge.net/projects/libusb/files/libusb-1.0/).

I ran the patch on that and did configure and make install on it and
it seemed fine. But when I compiled glView I just get this error:
Creating EP 81 transfer #0
Creating EP 81 transfer #1
Failed to submit xfer 1: -99
Creating EP 81 transfer #2
Failed to submit xfer 2: -99
Creating EP 81 transfer #3
Failed to submit xfer 3: -99
Xfer error: 1

and a white screen.

Thanks,
Mike
> >>>>>>>> On Wed, Nov 10, 2010 at 10:32 PM, Kyle Machulis <k...@nonpolynomial.com
> >>>>>>>> <mailto:k...@nonpolynomial.com>> wrote:
>
> >>>>>>>> Yeah. iso transfers are stalling on mac. This is usually an issue
> >>>>>>>> when developing mac libusb stuff, what works on linux requires some
> >>>>>>>> tweaking in OS X. Things may need to align on weird boundaries, etc...
>
> >>>>>>>> On Wed, Nov 10, 2010 at 9:52 PM, Vitor Calejuri
> >>>>>>>> <ondeosfrangosnaotem...@gmail.com
> >>>>>>>> <mailto:ondeosfrangosnaotem...@gmail.com>> wrote:
>
> >>>>>>>>     This may also help you debugging:
>
> >>>>>>>>    http://developer.apple.com/hardwaredrivers/download/usbdebug.html
>
> >>>>>>>>     On Thu, Nov 11, 2010 at 3:48 AM, Tim Hawkins <tim.hawk...@me.com

Christian Parsons

unread,
Dec 6, 2010, 11:00:40 AM12/6/10
to openk...@googlegroups.com
Hi, I have compiled libfreenect in Mac OSX (10.6.5) without problems following these instructions..
http://openkinect.org/wiki/Getting_Started#OS_X

but when I try to run glview it crashes with this error:

Isochronous transfer error: 1
Failed to submit isochronous transfer 1: -99
Failed to submit isochronous transfer 2: -99
Failed to submit isochronous transfer 3: -99

I have no problems running the openframeworks ofxKinect addon, which I think it has a modified version of libfreenect.. Maybe it has some code that fixes this issue..

But since libfreenect crashes with my build I can't run this tool.. 

Any clue on how to solve this?

thanks!

Christian Parsons
www.chparsons.com.ar

MikeManh

unread,
Dec 10, 2010, 2:19:17 AM12/10/10
to OpenKinect
That looks a lot like the problem I was having, except that problem
went away when I used libusb-devel. I had that problem back when I was
pulling the head repo out of git and was building libusb myself. Did
you try disconnecting other things?

On Dec 6, 11:00 am, Christian Parsons <chpars...@gmail.com> wrote:
> Hi, I have compiled libfreenect in Mac OSX (10.6.5) without problems
> following these instructions..http://openkinect.org/wiki/Getting_Started#OS_X
>
> but when I try to run glview it crashes with this error:
>
> Isochronous transfer error: 1
> Failed to submit isochronous transfer 1: -99
> Failed to submit isochronous transfer 2: -99
> Failed to submit isochronous transfer 3: -99
>
> I have no problems running the openframeworks ofxKinect addon, which I think
> it has a modified version of libfreenect.. Maybe it has some code that fixes
> this issue..
>
> But since libfreenect crashes with my build I can't run this tool..http://nicolas.burrus.name/index.php/Research/KinectRgbDemoV2
>
> Any clue on how to solve this?
>
> thanks!
>
> Christian Parsonswww.chparsons.com.ar
>

Juan Carlos del Valle

unread,
Dec 10, 2010, 2:38:08 AM12/10/10
to openk...@googlegroups.com
Hi mike, i made a pkg for my as3 server few days ago, this pkg also
installs usblib and the libfreenect include files. This has worked for
other people, perhaps this helps you to know if the libusb version is
the correct.

It installs libusb.h into /usr/local/include/libusb-1.0/ and the lib
into /usr/local/lib/

The pkg is available at http://www.as3kinect.org/download/

Hope this helps.

Christian Parsons

unread,
Dec 10, 2010, 8:02:52 AM12/10/10
to openk...@googlegroups.com
Ok! got it running with the version installed by http://www.as3kinect.org/

thanks!

Christian Parsons
www.chparsons.com.ar
Reply all
Reply to author
Forward
0 new messages