GithubHelp home page GithubHelp logo

array of devices - reopen about javacpp HOT 5 CLOSED

bytedeco avatar bytedeco commented on June 10, 2024
array of devices - reopen

from javacpp.

Comments (5)

saudet avatar saudet commented on June 10, 2024

from javacpp.

lobsteroh avatar lobsteroh commented on June 10, 2024

correct. so i assume my java wrapper is off ...

public static native void uvc_free_device_list(@Cast("uvc_device**") @ByPtrPtr PointerPointer<?> uvcDevList, @Cast("uint8_t") byte unref_devices);

any suggestion on how i can fix it? whatever i try to change on it, it either won't compile into the jar or give me a compile error when i call it from ...

UVCController.uvc_free_device_list (uvcDevList, (byte)1);

am at the end of my limited wisdom ...

from javacpp.

saudet avatar saudet commented on June 10, 2024

uvc_free_device_list() takes only a double pointer, so we don't need the @ByPtrPtr annotation. All that would be done automatically with the Parser BTW.

from javacpp.

lobsteroh avatar lobsteroh commented on June 10, 2024

thanks for the help, Samuel. I owe you quite a few drinks by now ... i am reviewing the final outcome of the issue for folks who end up here with similar questions.

the calls in the libuvc C library are ...

uvc_error_t uvc_get_device_list(uvc_context_t *ctx, uvc_device_t ***list) { .... }

and

void uvc_free_device_list(uvc_device_t **list, uint8_t unref_devices) { .... }

i am java wrapping them in the jlibuvc with ...

public static native int uvc_get_device_list(UVCContext ctx, @Cast("uvc_device***") @ByPtrPtr PointerPointer<?> uvcDevList);

and

public static native void uvc_free_device_list(@Cast("uvc_device**") PointerPointer<?> uvcDevList, @Cast("uint8_t") byte unref_devices);

i then make the calls do the work with the following code ...

public class UVCLoad { 
    public static void main(String... arg) throws InterruptedException {
        UVCDevice dev = new UVCController.UVCDevice();
        UVCContext ctx = new UVCController.UVCContext();
        UVCStreamCtrl sctrl = new UVCController.UVCStreamCtrl();
        System.out.println("Initialize : " + UVCController.uvc_init(ctx, null));

//      I could access the device directly with ...
//      System.out.println("Find Camera: " + UVCController.uvc_find_device(ctx, dev, 0x0, 0x0, null));
//      but in this example I get the list first, then pull the device at index 0 from it with ...
        PointerPointer<UVCDevice> uvcDevList = new PointerPointer<UVCDevice>();
        UVCController.uvc_get_device_list(ctx, uvcDevList);        
        dev = (UVCDevice) uvcDevList.get(UVCDevice.class, 0);

//      then I again free everything at the end.
        UVCController.uvc_free_device_list(uvcDevList,(byte)0);
        UVCController.uvc_unref_device(dev);
        UVCController.uvc_exit(ctx);
    }
}

i hope this helps ...

from javacpp.

saudet avatar saudet commented on June 10, 2024

You're welcome! :)

from javacpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.