cameleon-rs / cameleon

A safe, fast, and flexible library for GenICam compatible cameras
Mozilla Public License 2.0
85 stars 16 forks source link

How can this library be used in windows? #104

Closed apriori closed 3 years ago

apriori commented 3 years ago

Hello, I have a Point Grey Chameleon 3 5MP monochrome camera, which is known to be USB 3 vision compatible. How would I e.g. use that camera with this library? A minimal enumeration exchange claims that no camera has been found, although in the official SDK the camera is working just fine.

Y-Nak commented 3 years ago

Hi @apriori! Thanks for opening an issue and sorry for the late response.

To use cameleon on windows, you need to follow the steps below (I'll add the steps to README.md later).

1. Install libusb with vcpkg

Please see here to install libusb with vcpkg, though I assume you already have done this step.

2. Install a driver for your device with zadig

You can find the resource here for this step.

NOTE: please make sure to install a driver to a composite device, not to its child devices.

To do this, you need to list all devices connected to the host computer with zadig like below. zadig_list_option

Then install WinUSB to your device like below. zadig_composite_device

I think this official document would be helpful too.

Also, I found some bugs related to WinUSB and fixed it, so please pull the current main branch after the steps above and run examples like cargo run --example stream --features=libusb. I have tried running several u3v devices on windows and confirmed that they all work fine. But I don't have a Point Grey device, So could you run your device and report the result, please?

apriori commented 3 years ago

Thank you for your quick response and thorough explanation and instructions. I immediately attempted to try to use a "Chameleon 3 CM3-U3-50S5M" but failed with a panic in cameleon_genapi::formula::Parser::expect(...). The full expression string being parsed is (quoted for clarity on spaces):

"( EXP = 1 ) ? 0 : 1"

I'd love to attach the full offending xml, but unfortunately in the header the terms read like this:

<!--===========================================================
Copyright © 2016 Point Grey Research, Inc. All Rights Reserved.

This software is the confidential and proprietary information of
Point Grey Research, Inc. ("Confidential Information").  
You shall not disclose such Confidential Information and shall
use it only in accordance with the terms of the license
agreement you entered into with PGR.

PGR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY 
OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT 
LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. PGR SHALL NOT BE 
LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
============================================================-->

Maybe the stack trace is helpful to find out the exact issue:

                               at e:\rust\cameleon\genapi\src\formula.rs:597
  17:     0x7ff76fa7745e - cameleon_genapi::formula::Parser::call
                               at e:\rust\cameleon\genapi\src\formula.rs:494
  18:     0x7ff76fa7727d - cameleon_genapi::formula::Parser::pow
                               at e:\rust\cameleon\genapi\src\formula.rs:479
  19:     0x7ff76fa77238 - cameleon_genapi::formula::Parser::unop
                               at e:\rust\cameleon\genapi\src\formula.rs:474
  20:     0x7ff76fa76dfb - cameleon_genapi::formula::Parser::factor
                               at e:\rust\cameleon\genapi\src\formula.rs:450
  21:     0x7ff76fa76b5b - cameleon_genapi::formula::Parser::term
                               at e:\rust\cameleon\genapi\src\formula.rs:442
  22:     0x7ff76fa768bb - cameleon_genapi::formula::Parser::bit_shift
                               at e:\rust\cameleon\genapi\src\formula.rs:434
  23:     0x7ff76fa7654b - cameleon_genapi::formula::Parser::rel
                               at e:\rust\cameleon\genapi\src\formula.rs:424
  24:     0x7ff76fa762ab - cameleon_genapi::formula::Parser::eq
                               at e:\rust\cameleon\genapi\src\formula.rs:416
  25:     0x7ff76fa7608b - cameleon_genapi::formula::Parser::bitwise_and
                               at e:\rust\cameleon\genapi\src\formula.rs:412
  26:     0x7ff76fa75e6b - cameleon_genapi::formula::Parser::bitwise_xor
                               at e:\rust\cameleon\genapi\src\formula.rs:408
  27:     0x7ff76fa75c4b - cameleon_genapi::formula::Parser::bitwise_or
                               at e:\rust\cameleon\genapi\src\formula.rs:404
  28:     0x7ff76fa75a2b - cameleon_genapi::formula::Parser::logical_and
                               at e:\rust\cameleon\genapi\src\formula.rs:400
  29:     0x7ff76fa7580b - cameleon_genapi::formula::Parser::logical_or
                               at e:\rust\cameleon\genapi\src\formula.rs:396
  30:     0x7ff76fa75553 - cameleon_genapi::formula::Parser::expr
                               at e:\rust\cameleon\genapi\src\formula.rs:380
  31:     0x7ff76fa77576 - cameleon_genapi::formula::Parser::primary
                               at e:\rust\cameleon\genapi\src\formula.rs:508
  32:     0x7ff76fa7748e - cameleon_genapi::formula::Parser::call
                               at e:\rust\cameleon\genapi\src\formula.rs:502
  33:     0x7ff76fa7727d - cameleon_genapi::formula::Parser::pow
                               at e:\rust\cameleon\genapi\src\formula.rs:479
  34:     0x7ff76fa77238 - cameleon_genapi::formula::Parser::unop
                               at e:\rust\cameleon\genapi\src\formula.rs:474
  35:     0x7ff76fa76dfb - cameleon_genapi::formula::Parser::factor
                               at e:\rust\cameleon\genapi\src\formula.rs:450
  36:     0x7ff76fa76b5b - cameleon_genapi::formula::Parser::term
                               at e:\rust\cameleon\genapi\src\formula.rs:442
  37:     0x7ff76fa768bb - cameleon_genapi::formula::Parser::bit_shift
                               at e:\rust\cameleon\genapi\src\formula.rs:434
  38:     0x7ff76fa7654b - cameleon_genapi::formula::Parser::rel
                               at e:\rust\cameleon\genapi\src\formula.rs:424
  39:     0x7ff76fa762ab - cameleon_genapi::formula::Parser::eq
                               at e:\rust\cameleon\genapi\src\formula.rs:416
  40:     0x7ff76fa7608b - cameleon_genapi::formula::Parser::bitwise_and
                               at e:\rust\cameleon\genapi\src\formula.rs:412
  41:     0x7ff76fa75e6b - cameleon_genapi::formula::Parser::bitwise_xor
                               at e:\rust\cameleon\genapi\src\formula.rs:408
  42:     0x7ff76fa75c4b - cameleon_genapi::formula::Parser::bitwise_or
                               at e:\rust\cameleon\genapi\src\formula.rs:404
  43:     0x7ff76fa75a2b - cameleon_genapi::formula::Parser::logical_and
                               at e:\rust\cameleon\genapi\src\formula.rs:400
  44:     0x7ff76fa7580b - cameleon_genapi::formula::Parser::logical_or
                               at e:\rust\cameleon\genapi\src\formula.rs:396
  45:     0x7ff76fa75553 - cameleon_genapi::formula::Parser::expr
                               at e:\rust\cameleon\genapi\src\formula.rs:380
  46:     0x7ff76fa7a092 - cameleon_genapi::formula::parse
                               at e:\rust\cameleon\genapi\src\formula.rs:348
  47:     0x7ff76f89fcbd - cameleon_genapi::parser::formula::{{impl}}::parse<cameleon_genapi::store::DefaultNodeStore,cameleon_genapi::store::DefaultValueStore,cameleon_genapi::store::DefaultCacheStore>
                               at e:\rust\cameleon\genapi\src\parser\formula.rs:32
  48:     0x7ff76f89405a - cameleon_genapi::parser::xml::Node::parse<enum$<cameleon_genapi::formula::Expr>,cameleon_genapi::store::DefaultNodeStore,cameleon_genapi::store::DefaultValueStore,cameleon_genapi::store::DefaultCacheStore>
                               at e:\rust\cameleon\genapi\src\parser\xml.rs:45
  49:     0x7ff76f89fd50 - cameleon_genapi::parser::formula::{{impl}}::parse<cameleon_genapi::store::DefaultNodeStore,cameleon_genapi::store::DefaultValueStore,cameleon_genapi::store::DefaultCacheStore>
                               at e:\rust\cameleon\genapi\src\parser\formula.rs:19
  50:     0x7ff76f8946da - cameleon_genapi::parser::xml::Node::parse<cameleon_genapi::formula::Formula,cameleon_genapi::store::DefaultNodeStore,cameleon_genapi::store::DefaultValueStore,cameleon_genapi::store::DefaultCacheStore>
                               at e:\rust\cameleon\genapi\src\parser\xml.rs:45
  51:     0x7ff76f8babcc - cameleon_genapi::parser::int_swiss_knife::{{impl}}::parse<cameleon_genapi::store::DefaultNodeStore,cameleon_genapi::store::DefaultValueStore,cameleon_genapi::store::DefaultCacheStore>
                               at e:\rust\cameleon\genapi\src\parser\int_swiss_knife.rs:39
  52:     0x7ff76f8943ea - cameleon_genapi::parser::xml::Node::parse<cameleon_genapi::int_swiss_knife::IntSwissKnifeNode,cameleon_genapi::store::DefaultNodeStore,cameleon_genapi::store::DefaultValueStore,cameleon_genapi::store::DefaultCacheStore>
                               at e:\rust\cameleon\genapi\src\parser\xml.rs:45
  53:     0x7ff76f8e6f71 - cameleon_genapi::parser::{{impl}}::parse<cameleon_genapi::store::DefaultNodeStore,cameleon_genapi::store::DefaultValueStore,cameleon_genapi::store::DefaultCacheStore>
                               at e:\rust\cameleon\genapi\src\parser\mod.rs:179
  54:     0x7ff76f8949da - cameleon_genapi::parser::xml::Node::parse<alloc::vec::Vec<enum$<cameleon_genapi::store::NodeData>, alloc::alloc::Global>,cameleon_genapi::store::DefaultNodeStore,cameleon_genapi::store::DefaultValueStore,cameleon_genapi::store::DefaultCacheStore>
                               at e:\rust\cameleon\genapi\src\parser\xml.rs:45
  55:     0x7ff76f8a3826 - cameleon_genapi::parser::parse<alloc::string::String,cameleon_genapi::store::DefaultNodeStore,cameleon_genapi::store::DefaultValueStore,cameleon_genapi::store::DefaultCacheStore>
                               at e:\rust\cameleon\genapi\src\parser\mod.rs:71
  56:     0x7ff76f8a6868 - cameleon_genapi::builder::GenApiBuilder<cameleon_genapi::store::DefaultNodeStore, cameleon_genapi::store::DefaultValueStore, cameleon_genapi::store::DefaultCacheStore>::build<cameleon_genapi::store::DefaultNodeStore,cameleon_genapi::store::DefaultValueSto
                               at e:\rust\cameleon\genapi\src\builder.rs:39
  57:     0x7ff76f8a748b - cameleon::genapi::{{impl}}::from_xml<alloc::string::String>
                               at E:\rust\cameleon\cameleon\src\genapi\mod.rs:241
  58:     0x7ff76f8d5ee2 - cameleon::camera::Camera<cameleon::u3v::control_handle::ControlHandle, cameleon::u3v::stream_handle::StreamHandle, cameleon::genapi::DefaultGenApiCtxt>::load_context<cameleon::u3v::control_handle::ControlHandle,cameleon::u3v::stream_handle::StreamHandle,c
                               at E:\rust\cameleon\cameleon\src\camera.rs:248
  59:     0x7ff76f8eec04 - stream::main
                               at E:\rust\cameleon\cameleon\examples\stream.rs:23
apriori commented 3 years ago

Additional remark: a CM-U3-28S4M-CS fails at the very same expression.

apriori commented 3 years ago

Is there a possibility this term is misinterpreted as something like EXP(X) ?

Y-Nak commented 3 years ago

Thanks for your great detailed report!

Is there a possibility this term is misinterpreted as something like EXP(X)?

Exactly! I misread the GenICam specification which defines some keywords for functions. I think the fix would be straightforward but it's 4 a.m in my timezone, so I'll fix the issue tomorrow. Or please feel free to claim the issue if you want to try to fix it (No obligation, of course), https://github.com/cameleon-rs/cameleon/blob/main/genapi/src/formula.rs is the related module of the issue.

apriori commented 3 years ago

Continuation of this issue in #106

apriori commented 3 years ago

Instructions for windows usage are sufficient. Closing.