video for linux two (v4l2) bindings

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

video for linux two (v4l2) bindings

Claude Heiland-Allen-2
Greetings all,

I uploaded 4 new packages that may be of interest:

bindings-linux-videodev2 0.1
  - bindings to Video For Linux Two (v4l2) kernel interfaces
    http://hackage.haskell.org/package/bindings-linux-videodev2-0.1

bindings-mmap 0.1
  - bindings to mmap for POSIX
    http://hackage.haskell.org/package/bindings-mmap-0.1

bindings-libv4l2 0.1
  - bindings to libv4l2 for Linux
    http://hackage.haskell.org/package/bindings-libv4l2-0.1

v4l2-examples 0.1
  - video for linux two examples
    http://hackage.haskell.org/package/v4l2-examples-0.1

The first wraps the low-level structures and ioctls of the V4L2 API.

The second wraps the raw mmap/munmap functions and constants (which I
couldn't seem to find on hackage, only higher level wrappers which I
couldn't use for various reasons).  It would make more sense for this to
be folded into bindings-posix at some point.

The third wraps libv4l2, which provides an interface very similar to the
use of V4L2 ioctls, but the library adds extra capabilities behind the
scenes (I'm led to believe colour space conversion is one of them) which
is hopefully useful.

And the last is a crude example dumping frames from a video device (like
a webcam) to stdout in YUV4MPEG2 format.  The code is *very* low-level
and imperative (almost a direct translation from the C example provided
on the linuxtv API reference), there is plenty of room for a much nicer
layer to (for example) get video data into RePa arrays or OpenGL textures.

As these are raw bindings, documentation is best found upstream.

Thanks to Maurício C. Antunes's package for making this possible, I
recommend it:  http://hackage.haskell.org/package/bindings-DSL


Claude
--
http://claudiusmaximus.goto10.org

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: video for linux two (v4l2) bindings

Christopher Done
Sounds awesome! I was recently thinking I wanted a v4l-binding. In the
past I've patched vgrabbj so that I could pipe it and use it from
Haskell, but wanted a direct binding.

I just had a quick try with cabal-install and got the below. I'm not
sure where linux/posix_types is supposed to come from. Is this error
obvious to you?

Ciao!

Downloading bindings-linux-videodev2-0.1...
Configuring bindings-linux-videodev2-0.1...
Preprocessing library bindings-linux-videodev2-0.1...
In file included from Bindings/Linux/videodev2.h:62,
                 from VideoDev2.hsc:6:
/usr/include/linux/types.h:8:31: error: linux/posix_types.h: No such
file or directory
VideoDev2.hsc: In function ‘main’:
VideoDev2.hsc:1032: warning: cast from pointer to integer of different size
VideoDev2.hsc:1032: warning: cast from pointer to integer of different size
VideoDev2.hsc:1033: warning: cast from pointer to integer of different size
VideoDev2.hsc:1033: warning: cast from pointer to integer of different size
compiling dist/build/Bindings/Linux/VideoDev2_hsc_make.c failed
command was: /usr/bin/gcc -c -D__GLASGOW_HASKELL__=612
-IBindings/Linux/
-I/home/chris/.cabal/lib/network-2.3.0.4/ghc-6.12.3/include
-I/home/chris/Programs/lib/ghc-6.12.3/unix-2.4.0.2/include
-I/home/chris/Programs/lib/ghc-6.12.3/bytestring-0.9.1.7/include
-I/home/chris/.cabal/lib/bindings-DSL-1.0.11/ghc-6.12.3/include
-I/home/chris/Programs/lib/ghc-6.12.3/base-4.2.0.2/include
-I/home/chris/Programs/lib/ghc-6.12.3/include
-I/home/chris/Programs/lib/ghc-6.12.3/include
-I/home/chris/Programs/lib/ghc-6.12.3/include/
dist/build/Bindings/Linux/VideoDev2_hsc_make.c -o
dist/build/Bindings/Linux/VideoDev2_hsc_make.o

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: video for linux two (v4l2) bindings

Daniel Fischer
On Sunday 03 July 2011, 21:34:17, Christopher Done wrote:
> I just had a quick try with cabal-install and got the below. I'm not
> sure where linux/posix_types is supposed to come from. Is this error
> obvious to you?

glibc-devel or the equivalent package for your distro, I think.

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: video for linux two (v4l2) bindings

Christopher Done
On 3 July 2011 21:46, Daniel Fischer <[hidden email]> wrote:
> On Sunday 03 July 2011, 21:34:17, Christopher Done wrote:
>> I just had a quick try with cabal-install and got the below. I'm not
>> sure where linux/posix_types is supposed to come from. Is this error
>> obvious to you?
>
> glibc-devel or the equivalent package for your distro, I think.

It turned out that I needed the linux development files from
linux-libc-dev. FWIW to anyone, I'm on Ubuntu. The packages I
installed were:

sudo apt-get install linux-libc-dev
sudo apt-get install libv4l-dev

Then I got this problem:

/home/chris/Programs/bin/ghc --make -o
dist/build/v4l2-capture/v4l2-capture -hide-all-packages
-fbuilding-cabal-package -package-conf dist/package.conf.inplace -i
-idist/build/v4l2-capture/v4l2-capture-tmp -i. -idist/build/autogen
-Idist/build/autogen -Idist/build/v4l2-capture/v4l2-capture-tmp
-optP-include -optPdist/build/autogen/cabal_macros.h -odir
dist/build/v4l2-capture/v4l2-capture-tmp -hidir
dist/build/v4l2-capture/v4l2-capture-tmp -stubdir
dist/build/v4l2-capture/v4l2-capture-tmp -package-id
base-4.2.0.2-5fc3ebcb886ceae9a06b0bab7e8d4680 -package-id
bindings-libv4l2-0.1-8dde216a9ec82cb90bbe93e20783ff8c -package-id
bindings-linux-videodev2-0.1-7a032e0014085bf53e381d004d794b50
-package-id bindings-mmap-0.1-3144f93204d922458a3be21650b85f1f
-package-id bindings-posix-1.2.2-00b879b119996c2d3acc7989dde2ba63
-package-id c-io-0.1.0-dcc629f98d0e4b2e0d55acbaaa6262b6 -package-id
ioctl-0.0.1-60f1d8091a07bb23f1736fec7d2b4dd8 -O -Wall
./src/v4l2-capture.hs
[1 of 1] Compiling Main             ( src/v4l2-capture.hs,
dist/build/v4l2-capture/v4l2-capture-tmp/Main.o )
Linking dist/build/v4l2-capture/v4l2-capture ...
/usr/bin/ld: /home/chris/.cabal/lib/bindings-posix-1.2.2/ghc-6.12.3/libHSbindings-posix-1.2.2.a(Signal.o):(.text+0x5dfb):
error: undefined reference to 'pthread_kill'
/usr/bin/ld: /home/chris/.cabal/lib/bindings-posix-1.2.2/ghc-6.12.3/libHSbindings-posix-1.2.2.a(Signal.o):(.text+0x5ee2):
error: undefined reference to 'pthread_kill'
/usr/bin/ld: /home/chris/.cabal/lib/bindings-posix-1.2.2/ghc-6.12.3/libHSbindings-posix-1.2.2.a(Signal.o):(.text+0x5f87):
error: undefined reference to 'pthread_sigmask'
/usr/bin/ld: /home/chris/.cabal/lib/bindings-posix-1.2.2/ghc-6.12.3/libHSbindings-posix-1.2.2.a(Signal.o):(.text+0x6092):
error: undefined reference to 'pthread_sigmask'
collect2: ld returned 1 exit status
cabal: Error: some packages failed to install:
v4l2-examples-0.1 failed during the building phase. The exception was:
ExitFailure 1
chris@cn-done:~/v4l2-examples-0.1$

But I solved it by adding -lpthread:

chris@cn-done:~/v4l2-examples-0.1$ /home/chris/Programs/bin/ghc --make
-o dist/build/v4l2-capture/v4l2-capture -hide-all-packages
-fbuilding-cabal-package -package-conf dist/package.conf.inplace -i
-idist/build/v4l2-capture/v4l2-capture-tmp -i. -idist/build/autogen
-Idist/build/autogen -Idist/build/v4l2-capture/v4l2-capture-tmp
-optP-include -optPdist/build/autogen/cabal_macros.h -odir
dist/build/v4l2-capture/v4l2-capture-tmp -hidir
dist/build/v4l2-capture/v4l2-capture-tmp -stubdir
dist/build/v4l2-capture/v4l2-capture-tmp -package-id
base-4.2.0.2-5fc3ebcb886ceae9a06b0bab7e8d4680 -package-id
bindings-libv4l2-0.1-8dde216a9ec82cb90bbe93e20783ff8c -package-id
bindings-linux-videodev2-0.1-7a032e0014085bf53e381d004d794b50
-package-id bindings-mmap-0.1-3144f93204d922458a3be21650b85f1f
-package-id bindings-posix-1.2.2-00b879b119996c2d3acc7989dde2ba63
-package-id c-io-0.1.0-dcc629f98d0e4b2e0d55acbaaa6262b6 -package-id
ioctl-0.0.1-60f1d8091a07bb23f1736fec7d2b4dd8 -O -Wall
./src/v4l2-capture.hs -lpthread
Linking dist/build/v4l2-capture/v4l2-capture ...
chris@cn-done:~/v4l2-examples-0.1$

I guess on Claude's system it's linked to by default. So for guys
trying the examples with that error I'd recommend the following
commandline:

  cabal install v4l2-examples --ghc-option=-lpthread

Can't really play about with the webcam right now but I'd had a small
but cool project I've had in mind for a while that v4l is perfectly
suited for, so I'll get back to you with my experiences. Thanks for
releasing it, Claude. :-)

Ciao!

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: video for linux two (v4l2) bindings

Claude Heiland-Allen-2
Hi,

On 05/07/11 10:19, Christopher Done wrote:
[snip]
> /usr/bin/ld: /home/chris/.cabal/lib/bindings-posix-1.2.2/ghc-6.12.3/libHSbindings-posix-1.2.2.a(Signal.o):(.text+0x5dfb):
> error: undefined reference to 'pthread_kill'
[snip]
> I guess on Claude's system it's linked to by default.  So for guys
> trying the examples with that error I'd recommend the following
> commandline:
>
>    cabal install v4l2-examples --ghc-option=-lpthread

I think this could be a bug in bindings-posix (maintainer CC'd), I guess
it could do with this in its .cabal file:

     Extra-libraries: pthread

> Can't really play about with the webcam right now but I'd had a small
> but cool project I've had in mind for a while that v4l is perfectly
> suited for, so I'll get back to you with my experiences. Thanks for
> releasing it, Claude. :-)

Cool, look forward to seeing it!  Hopefully I'll soon find time to
upload to Hackage a preliminary (feature-incomplete) release of the
higher-level interface that I'm working on; until then:
https://gitorious.org/hsv4l2/v4l2


Claude
--
http://claudiusmaximus.goto10.org

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: video for linux two (v4l2) bindings

Maurí­cio CA
Hi, all,

I've added that 'extra-libraries' to .cabal, and also modules for fcntl.h
and sys/mman.h (mmap). Would you please test it and check if it solves
the problem before I upload it to hackage?

  https://bitbucket.org/mauricio/bindings-dsl/downloads/bindings-posix-1.2.3.tar.gz

Just download from that link, unpack and do 'cabal install' inside the
new directory.

Best,
Maurício


2011/7/8, Claude Heiland-Allen <[hidden email]>:

> Hi,
>
> On 05/07/11 10:19, Christopher Done wrote:
> [snip]
>> /usr/bin/ld:
>> /home/chris/.cabal/lib/bindings-posix-1.2.2/ghc-6.12.3/libHSbindings-posix-1.2.2.a(Signal.o):(.text+0x5dfb):
>> error: undefined reference to 'pthread_kill'
> [snip]
>> I guess on Claude's system it's linked to by default.  So for guys
>> trying the examples with that error I'd recommend the following
>> commandline:
>>
>>    cabal install v4l2-examples --ghc-option=-lpthread
>
> I think this could be a bug in bindings-posix (maintainer CC'd), I guess
> it could do with this in its .cabal file:
>
>      Extra-libraries: pthread
>
>> Can't really play about with the webcam right now but I'd had a small
>> but cool project I've had in mind for a while that v4l is perfectly
>> suited for, so I'll get back to you with my experiences. Thanks for
>> releasing it, Claude. :-)
>
> Cool, look forward to seeing it!  Hopefully I'll soon find time to
> upload to Hackage a preliminary (feature-incomplete) release of the
> higher-level interface that I'm working on; until then:
> https://gitorious.org/hsv4l2/v4l2
>
>
> Claude
> --
> http://claudiusmaximus.goto10.org
>

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe