kingoflolz / fiducial

A LFTag and TopoTag implementation in Rust
MIT License
17 stars 4 forks source link

what would it take to get this compiled on a mac? #1

Open vshesh opened 4 years ago

vshesh commented 4 years ago

Hi,

Read your paper and saw this implementation which is exciting. Want to use LFTags in a project I'm working on, but cannot get this to compile on a mac. cargo build uses the v4l2 library somewhere in the dependency chain and this causes the build to fail:

   Compiling rscam v0.5.5
   Compiling deflate v0.7.20
   Compiling stb_truetype v0.3.1
error: rscam (v4l2) is for linux/freebsd only
  --> /Users/Vishesh/.cargo/registry/src/github.com-1ecc6299db9ec823/rscam-0.5.5/src/lib.rs:28:1
   |
28 | compile_error!("rscam (v4l2) is for linux/freebsd only");
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0425]: cannot find value `VIDIOC_STREAMON` in module `v4l2`
   --> /Users/Vishesh/.cargo/registry/src/github.com-1ecc6299db9ec823/rscam-0.5.5/src/lib.rs:690:37
    |
690 |         v4l2::xioctl(self.fd, v4l2::VIDIOC_STREAMON, &mut typ)?;
    |                                     ^^^^^^^^^^^^^^^ not found in `v4l2`

error[E0425]: cannot find value `VIDIOC_STREAMOFF` in module `v4l2`
   --> /Users/Vishesh/.cargo/registry/src/github.com-1ecc6299db9ec823/rscam-0.5.5/src/lib.rs:697:37
    |
697 |         v4l2::xioctl(self.fd, v4l2::VIDIOC_STREAMOFF, &mut typ)?;
    |                                     ^^^^^^^^^^^^^^^^ not found in `v4l2`

   Compiling quote v1.0.3
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0425`.
error: could not compile `rscam`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

is there some alternate way to get this working without rscam/v4l2 - some mac equivalent?

kingoflolz commented 4 years ago

I think the dependency comes from camera_capture, which unfortunately only supports Windows and Linux. I think that actually should be a dev dependency, as its not required for detecting or localizing LFTags in images, and is only required for the example code which detects tags from the webcam.

If you are interested in detecting tags in images/videos, try to move the camera_capture dependency into dev-dependencies (and if it works, a pull request with that modification would be great), but if you want to detect tags from the webcam, there is no rust library for webcam capture as far as I know.

vshesh commented 4 years ago

I have moved the dependency to dev as you suggested, and now am encountering a different error (I guess it finished building dependencies and is now trying to build the package)...

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> src/lib.rs:1:1
  |
1 | #![feature(test)]
  | ^^^^^^^^^^^^^^^^^

do you build against nightly/is there some other way to build this?

also as far as reading video frames goes - I notice you have opencv as a dependency. does it's VideoCapture module not work for reading frames from a webcam? (I would like to detect using a webcam, hence I ask)

thanks again for all the help and sure if i get this working I can make a pull request

vshesh commented 3 years ago

Hi,

back to trying to get this to work.

I have changed the imageproc depedency to 0.19.0 from 0.18.0 to solve a compiler error (imageproc 0.18 doesn't compile on rust stable > 1.48), and now am seeing:

error[E0277]: the trait bound `Luma<u16>: image::traits::Pixel` is not satisfied
   --> src/decode.rs:316:5
    |
316 | /     pub fn decode_lftag(root: &LFTagComponents, camera: CameraIntrinsics, gradient: &mut Image<Luma<u16>>) -> Option<DecodedLFTag> {
317 | |         if let LFTagComponents::Root { nodes, class, bg } = root {
318 | |             let mut fvs: Vec<_> = nodes.iter().map(|n| {
319 | |                 if let LFTagComponents::Normal {node: fv} = n {
...   |
554 | |         }
555 | |     }
    | |_____^ the trait `image::traits::Pixel` is not implemented for `Luma<u16>`

error: aborting due to previous error; 22 warnings emitted

For more information about this error, try `rustc --explain E0277`.
error: could not compile `fiducial`

How do I go about figuring out what type signature would work? I checked the image crate documentation and found nothing that would explain why Luma<u16> doesn't work and what I could replace it with.

Thanks in advance.

kingoflolz commented 3 years ago

I suspect the issue is that the versions of imageproc and image need to be aligned, try bumping the image crate version too?

For easier discussion, would you mind joining the rust-cv discord? I often hang out there (I go by @kindiana there) and I think synchronously working through these issues would be easier.

vshesh commented 3 years ago

alright, i'm joining the discord. thank you for all the help. bumping the image crate and image proc to newest versions didn't help - generated more errors, actually.