B4J Question Web Camera?

Discussion in 'B4J Questions' started by vdudukov, Dec 27, 2013.

  1. vdudukov

    vdudukov Member Licensed User

    Hi,

    Is it possible to take picture from webcamera?

    Thanks!
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Currently there isn't any library that supports web cams.
     
  3. CanguroCode

    CanguroCode Active Member Licensed User

    Erel, do you think at some point you will add some functionality to use the webcam? would be great
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Maybe in the future. If there is an open source Java project that already implements it then it will be more feasible.
     
  5. Daestrum

    Daestrum Well-Known Member Licensed User

    I have had some success using vlcj and can get the video from the webcam to be displayed.
    (Using swing controls)
    Unfortunately, the documentation is 'sketchy' to say the least, so major trial and error to see what else it can do. :mad:

    I now have the image from the webcam appearing in a javafx canvas object.:D
    It requires VLC to be installed on the machine, but that's probably 90% of users anyway.

    Erel I can give you the source I have working at present if that helps.
     
    Last edited: Jan 20, 2014
    CanguroCode likes this.
  6. CanguroCode

    CanguroCode Active Member Licensed User

    Erel, me too have a code in some place maybe will be useful for you.
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    If you can please release your library.
     
  8. Daestrum

    Daestrum Well-Known Member Licensed User

    Currently trying to make the code a tad more user friendly. Needs hard coded dll locations in at present.
     
  9. dilettante

    dilettante Active Member Licensed User

    Er, not on this planet. Not even among PC enthusiasts.

    But getting it to work at all is an accomplishment.
     
  10. swissmade

    swissmade Active Member Licensed User

    If it can help for Mjpeg.
    There is a good Javaplayer called cambozola
    http://www.charliemouse.com/code/cambozola/
    I have used this before and also have a version without Main to skip the Applet part.
    But I don't get it working in B4J. I had this perfect working in Jabaco
    Maybe somebody;) else will.
     
  11. CanguroCode

    CanguroCode Active Member Licensed User

    Erel, there is a Java project open source (MIT Licence) called Webcam Capture:

    Page: http://webcam-capture.sarxos.pl/
    Github: https://github.com/sarxos/webcam-capture

    This library allows you to use your build-in or external webcam directly from Java. It's designed to abstract commonly used camera features and support multiple capturing farmeworks.

    Features
    • Simple, thread-safe and non-blocking API,
    • No additional software required,
    • Supports multiple platforms (Windows, Linux, Mac OS, etc) and various architectures (32-bit, 64-bit, ARM),
    • Get images from build-in or USB-connected PC webcams,
    • Get images from IP / network cameras (as MJPEG or JPEG),
    • Offers ready to use motion detector,
    • All required JARs Available in Maven Central,
    • Offers possibility to expose images as MJPEG stream,
    • It is available as Maven dependency or standalone ZIP binary (with all dependencies included),
    • Swing component to display video feed from camera,
    • Swing component to choose camera (drop down),
    • Multiple capturing frameworks are supported:
      • OpenIMAJ,
      • LTI CIVIL,
      • Java Media Framework (JMF),
      • Freedom for Media in Java (FMJ),
      • OpenCV via JavaCV,
      • VLC via vlcj,
      • GStreamer (0.10.x only) via gstreamer-java
      • MJPEG IP Cameras,
    License

    (Extract from license)
    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software..

    This may help anything? Is it possible to make a library of this?
     
    inakigarm and ellpopeb4a like this.
  12. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    I had some success using this library through JavaObject Library :

    This is an example from their website converted to B4J .

    Do not forget to copy webcam-capture-0.3.10.jar , bridj-0.6.2.jar and slf4j-api-1.7.2.jar to Library folder .

    Add references :

    Code:
    #AdditionalJar : webcam-capture-0.3.10 
        
    #AdditionalJar : slf4j-api-1.7.2
        
    #AdditionalJar : bridj-0.6.2
    And use this sub

    Code:
    Sub JustToTest
        
    Private WebCam,ImageIO,BufferedImage,FileIO,Dimension As JavaObject

        FileIO=    FileIO.InitializeNewInstance(
    "java.io.File",Array("test1.png"))
        ImageIO.InitializeStatic(
    "javax.imageio.ImageIO")
        WebCam.InitializeStatic(
    "com.github.sarxos.webcam.Webcam")
        
    Try
            WebCam=WebCam.RunMethod(
    "getDefault",Null)
            
    Log("Default cam : "&WebCam)
        
    Catch
            
    Log(LastException.Message)
        
    End Try
        
    Try
            WebCam.RunMethod(
    "setViewSize",Array(Dimension.InitializeNewInstance("java.awt.Dimension",Array(640,480))))
            
    Log("Open: "&WebCam.RunMethod("open",Null))
           
        
    Catch
            
    Log(LastException.Message)
        
    End Try
       
        BufferedImage.InitializeStatic(
    "java.awt.image.BufferedImage")
        BufferedImage=WebCam.RunMethod(
    "getImage",Null)
       
        ImageIO.RunMethod(
    "write",Array(BufferedImage, "PNG", FileIO))
       
        
    Log("Close: "&WebCam.RunMethod("close",Null))
       
       

    End Sub
    My CyberLink built-in YouCam must be started or I will get their logo and a message instead of my face :) .

    [​IMG]
     
  13. CanguroCode

    CanguroCode Active Member Licensed User

    my god!, it works perfectly with my webcam on my lap (generic i tink)... Sorry for my image, the web cam that would not advise taking the picture :)

    Thanks a lot! really

    [​IMG]
     
    Erel likes this.
  14. CanguroCode

    CanguroCode Active Member Licensed User

    I upload the project and i put the link to download the libraries for others to do tests and see the operation in different cameras.
    I've never done a library, it will be very difficult to make? I think it would be even easier if we had a native library in B4J

    Regards

    Libs Link (I cant upload in the forum because >500K)
     

    Attached Files:

  15. CanguroCode

    CanguroCode Active Member Licensed User

    I Try to follow this post to create the library:
    http://www.b4x.com/android/forum/th...uild-libraries-without-eclipse.29918/#content

    I put the contents of src and libs of the Webcam folder, when compiling gave me the following log:

    This are the Java files:

    [​IMG]


    And this is the libs folder:

    [​IMG]

    I think I have to do something before, maybe in Java, but do not really know.

    Can you help?
     
    Last edited: Apr 25, 2015
  16. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    I do not think we need Java files to make it work .
    You can check attached file which I think can be compiled to library if you want .
    But anyway I beleive we need to reference library 3 JARs .
     

    Attached Files:

  17. HARRY

    HARRY Active Member Licensed User

    I would be glad to test this solution, as I am struggling quite some time with fswebcam. See my post Problem with file exists

    Some basic questions:

    Where to store the libs ? In additional libraries and or in the project folder.

    How to reference those libs? They do not appear in the libs list.

    Harry
     
    Last edited: Apr 25, 2015
  18. CanguroCode

    CanguroCode Active Member Licensed User

    Thanks for the interest. I'll check the attachment in a few moments more.
     
    Last edited: Apr 25, 2015
  19. CanguroCode

    CanguroCode Active Member Licensed User

    Where to store the libs ? In additional libraries and or in the project folder.
    I put them in the default libraries

    How to reference those libs? They do not appear in the libs list.
    Check the image below and the attachment project in the entry #14 if you have the libs in the default folder then you only must run it.

    [​IMG]
     
  20. CanguroCode

    CanguroCode Active Member Licensed User

    Ok I get it. So when you have an api, there's no point do the lib and better access to it directly by creating a class. Is this correct?

    For the record: The mega link I posted at the entrance # 14 are the files webcam-capture-0.3.10.jar, bridj-0.6.2.jar and slf4j-api-1.7.2.jar, are not all libraries .
    At the entrance # 15 I mention all libraries, because to my knowledge, are needed to compile the native library for b4j. Please correct me if I'm wrong.
     
    Last edited: Apr 26, 2015
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice