Git Product home page Git Product logo

visicam's Introduction

VisiCam

A Java application, that turns a webcam into a VisiCut compatible network camera with marker detection and perspective correction. Uses OpenCV through JavaCV

For detailed information, please have a look at the VisiCam Wiki.

Compile and Run

  1. Download JavaCV:
  • On Linux: Simply run ./lib/fetch-javacv.sh on the command line in the unzipped VisiCam directory.
  • On Windows: Read the instructions in that file (Download and unpack ZIP).
  1. Make sure you have apache-ant, java jdk >=6 and openCv installed (see below for OS-specific instructions)
  2. Go in the unzipped VisiCam directory and run ant on the command line
  3. run java -jar dist/VisiCam.jar on the Command Line or double click on the VisiCam.jar file in finder/explorer

Running on the Raspberry Pi

If you use it on ARM, you need to replace the javacv.jar in the dist/lib folder with the javacv.jar from the lib/javacv-pi folder. It works on ArchLinux (opencv can be installed through pacman). But is VERY SLOW. Any help is appreciated.

TODO: currently broken?

Running on Windows

Running on Ubuntu

Install the required dependencies with: sudo apt-get install openjdk-8-jdk ant libopencv2.4

You can also have a look at the Dockerfile for a more up-to-date list of all commands.

Usage

The following is a short summary of how to use VisiCut. For more detailed information, have a look at the VisiCam Wiki.

  1. Place 4 Markers (Circles within circles) near the corners of you laser-bed. For a first test, almost any configuration is okay, for example like this. Detailed information on how to achieve a professional set-up can be found in the VisiCam Wiki.
  2. Place a webcam over the laser-cutter, so that it's image contains all the markers.
  3. Connect the webcam to a PC running VisiCam.
  4. Go to you webbrowser and enter the VisiCam URL (is shown in the window after starting VisiCam).
  5. Click on "Refresh" on the left side to check if the camera is working and the markers are visible.
  6. Click on "Show Configuration". Here you can specify the resolutions and more important:
  7. For each Marker-Position (top-left, top-right, bottom-left, bottom-right) select a rectangle on the image, where VisiCam should search the marker
  8. Save the configuration with a click on the save-button
  9. In VisiCut go to Preferences -> Manage Lasercutters -> Edit and enter the CameraURL, which is <VisiCam URL>/image. If you have the latest version, you can just click "search" and all VisiCam instances in your Network should appear.
  10. You should see now the image from the webcam. To calibrate the camera go in Visicut to Options -> Calibrate Camera... and choose a laser setting. Then click on the Send Calibration Page-Button. VisiCut will send a calibration file to your lasercutter. It will cut two crosses (with the choosen settings) at (20%/20%) and (80%/80%) of the laser-bed. In the following dialog, you have to take a picture and move the red reference crosses matching to the ones you did just cut.
  11. Be happy with your VisiCam ;)

visicam's People

Contributors

t-oster avatar mgmax avatar frochr123 avatar peteruithoven avatar kr4cker avatar sedrubal avatar

Stargazers

Sean Clancy avatar Divya Pujara avatar Marcel Ochsendorf avatar Aurodev avatar  avatar Vsevolod Balashov avatar Vladimir Pilat avatar DiGiTAL_CuRSe avatar  avatar Christoph Kummer avatar David Malpica avatar David Walsh avatar Chris James avatar  avatar  avatar Sakib Sami avatar Mac Cowell avatar Boris Smirnov avatar Brian Bland avatar Sean Stevens avatar  avatar Lars Norpchen avatar  avatar  avatar Venkat avatar Abdelwahed Khamis avatar Pham Tuan Minh avatar Pantelis Koukousoulas avatar  avatar  avatar Tom Bielecki avatar  avatar codepainter avatar  avatar  avatar  avatar

Watchers

Poul Bundgaard avatar Tom Bielecki avatar James Cloos avatar Brian Bland avatar  avatar  avatar  avatar  avatar Venkat avatar

visicam's Issues

Config does not save when Raspi integration disabled

saving the settings fails for each of the following:

  • InactivitySeconds is empty
  • Raspi integration disabled

In this case, there is no error message visible, the save button just does nothing

suggested fixes

  • settings HTML page should display an error, not just skip the success message
  • VisiCam should ignore invalid values, or the JavaScript should disallow an empty value

OpenCV Capture or Webcam Capture ?

I'd like to get VisiCam working. Preferably on a as simple as possible computer, probably a raspberry pi. (A TP-link MR3020 with OpenWRT would be even nicer, but that's probably not possible)
I see you have a branch where you're using webcam feature using the following library.
https://github.com/sarxos/webcam-capture
Which branch should I pick? What is the status of the webcam capture branch?

Update

Would it be possible to compile this on the newest OpenCV + JavaCV release?

"libjniopencv_core.so: cannot open shared object file: No such file or directory"

After trying the following installation method

sudo apt-get update
sudo apt-get install libopencv-dev
sudo apt-get install python-opencv
sudo apt-get install ant
sudo apt-get install openjdk-7-jdk

Maybe the right java needs to be selected?
sudo update-alternatives --config java
select: "/usr/lib/jvm/java-7-openjdk-armhf/jre/bin/java"

Install the camera, see:
http://www.raspberrypi.org/camera

cd ~
git clone https://github.com/t-oster/VisiCam.git
cd VisiCam
sudo cp javacv-pi/javacv.jar javacv-bin/
ant jar
java -jar dist/VisiCam.jar

Configure it to use the pi camera:
Goto: localhost:8080/configPage.html
Check "CustomCapture"
CaptureCommand: raspistill -o image.jpg
CaptureResult: image.jpg

And press save I have the following in the terminal:

Listening on http://192.168.1.165:8080. Hit Enter to stop.

Responding to discovery packets on UDP:8888
Exception in thread "Thread-7" java.lang.UnsatisfiedLinkError: /tmp/javacpp860851686547/libjniopencv_core.so: /tmp/javacpp860851686547/libjniopencv_core.so: cannot open shared object file: No such file or directory
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1953)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1878)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1839)
    at java.lang.Runtime.load0(Runtime.java:795)
    at java.lang.System.load(System.java:1061)
    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:422)
    at com.googlecode.javacpp.Loader.load(Loader.java:372)
    at com.googlecode.javacpp.Loader.load(Loader.java:319)
    at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:131)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:270)
    at com.googlecode.javacpp.Loader.load(Loader.java:338)
    at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:96)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:270)
    at com.googlecode.javacpp.Loader.load(Loader.java:338)
    at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:91)
    at com.googlecode.javacv.OpenCVFrameGrabber.start(OpenCVFrameGrabber.java:170)
    at com.t_oster.visicam.CameraController.takeSnapshot(CameraController.java:53)
    at com.t_oster.visicam.VisiCamServer.serveRawImage(VisiCamServer.java:126)
    at com.t_oster.visicam.VisiCamServer.serve(VisiCamServer.java:137)
    at gr.ktogias.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:443)
    at java.lang.Thread.run(Thread.java:724)

I'm probably missing something around opencv...
I'll also be looking into this myself some more.

Raspberry Pi installation

I've bin trying to get VisiCam working on a Raspberry Pi.

I've done:

sudo apt-get update
sudo apt-get install libopencv-dev
sudo apt-get install python-opencv
sudo apt-get install ant
sudo apt-get install openjdk-7-jre
git clone https://github.com/t-oster/VisiCam.git
cd VisiCam
sudo cp javacv-pi/javacv.jar javacv-bin/
sudo ant jar

This gives:

BUILD FAILED
/VisiCam/nbproject/build-impl.xml:940: The following error occurred while executing this line:
/VisiCam/nbproject/build-impl.xml:293: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-6-openjdk-armhf/jre"

While this does exist?

pi@raspberrypi /usr/lib/jvm/java-6-openjdk-armhf/jre $ ls
ASSEMBLY_EXCEPTION  bin  lib  man  THIRD_PARTY_README

I'm not sure I understand the following Readme instructions, where is this dist/lib folder for example?

If you use it on ARM, you need to replace the javacv.jar in the dist/lib folder with the javacv.jar from the lib/javacv-pi folder. It works on ArchLinux (opencv can be installed through pacman). But is VERY SLOW. Any help is appreciated.

My translation was doing (like mentioned above):

sudo cp javacv-pi/javacv.jar javacv-bin/

run as system service

VisiCam should run as a background service because people like to close the "unnecessary" window.

mostly a reminder for myself.

  • make it work without GUI (or workaround with Xvfb?)
  • output to stdout (then to log via start-stop-daemon)
  • write initscript for debian and upstart-config for ubuntu
  • any network user can currently execute arbitrary commands via the "capture command" setting. lock this somehow.

cache response for concurrent requests

In our setup, capturing with an external script takes about 2 seconds. Because VisiCut is open on multiple lab PCs, a few requests come to VisiCam in parallel. They are served one after each other, instead of taking one picture and serving it to all hosts that requested an image while the picture was being taken.

Installing VisiCam on Raspberry Pi running Arch Linux

I've bin trying to install VisiCam on a Raspberry Pi, this time on Arch Linux:
https://github.com/t-oster/VisiCam/wiki/Raspberry-Pi-installation-(Arch-Linux)

It seems to be installed correctly, I'm able to take snapshots, configure the marker locations. But it can't generate the corrected image. Going to the main page I get the error:

Taking Snapshot...
Finding markers...
Exception in thread "Thread-26" java.lang.UnsatisfiedLinkError: com.googlecode.javacpp.Pointer$NativeDeallocator.deallocate(JJ)V
    at com.googlecode.javacpp.Pointer$NativeDeallocator.deallocate(Native Method)
    at com.googlecode.javacpp.Pointer$NativeDeallocator.deallocate(Pointer.java:145)
    at com.googlecode.javacpp.Pointer$DeallocatorReference.clear(Pointer.java:193)
    at com.googlecode.javacpp.Pointer.deallocateReferences(Pointer.java:202)
    at com.googlecode.javacpp.Pointer.deallocator(Pointer.java:253)
    at com.googlecode.javacpp.Pointer.init(Pointer.java:78)
    at com.googlecode.javacv.cpp.opencv_core$CvSize.allocate(Native Method)
    at com.googlecode.javacv.cpp.opencv_core$CvSize.<init>(opencv_core.java:2525)
    at com.googlecode.javacv.cpp.opencv_core.cvSize(opencv_core.java:2559)
    at com.googlecode.javacv.cpp.opencv_core$IplImage.create(opencv_core.java:419)
    at com.googlecode.javacv.cpp.opencv_core$IplImage.createFrom(opencv_core.java:509)
    at com.googlecode.javacv.cpp.opencv_core$IplImage.createFrom(opencv_core.java:481)
    at com.googlecode.javacv.cpp.opencv_core$IplImage.createFrom(opencv_core.java:478)
    at com.t_oster.visicam.CameraController.findMarker(CameraController.java:105)
    at com.t_oster.visicam.VisiCamServer.serveTransformedImage(VisiCamServer.java:175)
    at com.t_oster.visicam.VisiCamServer.serve(VisiCamServer.java:141)
    at gr.ktogias.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:443)
    at java.lang.Thread.run(Thread.java:722)

Size and position configuration

So VisiCam it working, now comes configuration.
screen shot 2013-11-20 at 2 32 11 pm

I don't get how I can configure the size. Currently the image is quite enlarged and the what is shown doesn't really match the real world size. Are we missing a scale setting or don't I understand the system?

Also, the marker is put a bit above the 0,0 point of the lasercutter, because otherwise the marker would be obfuscated by the laser head. How should I solve this? Are we missing offset features?

return error image when marker not detected

If the marker cannot be found (e.g. when the camera has overexposure problems), no output image should be returned. I suggest returning a completely blue image or an error message (how?).

Visicam still broken

Visicam looks like it has been abandoned. This is a pity.
The problem seems to always be the same as indicated by the previous issue. The Java dependencies used no longer exist for a few updates.
If the project is dead, it would be nice if the github was closed.

Raspberry Pi GPU Integration broken?

According to the README, using VisiCam on the Raspberry Pi (ARM processor) and/or the RPiGPU integration is broken. I guess this comes from updating to a newer JavaCV version. The files in https://github.com/t-oster/VisiCam/tree/master/lib/javacv-pi should be updated or, even better, be replaced with a script which compiles them automatically.

There is also a lack of documentation on the RPiGPU integration, I even had to google it to find the repository https://github.com/FroChr123/visicamRPiGPU .

Capture taking takes a while

Currently my setup on the Raspberry Pi, using pistill, with image resolution of 720x576 pixels it takes about 33 seconds for the capture to appear in VisiCut after pressing the capture button.
That's one to improve upon in the future.
Moving the heavy stuff to a c++ app might speed things up. I started on a openFrameworks version:
screen shot 2013-11-18 at 9 50 37 pm

Replace Round markers by Line-Detection of Laser-Bed edges

It is not very pleasant to add markers to the laser-bed. Since most laser-beds are rectangular, it may be possible to just run a line-detection algorithm on the image and find the outer-most and most-perpendicular rectangle and use that for the homography. This way nearly any Lasercutter can be used without preparation, just place a camera above it and maybe mark the areas where the algorithm shall search for the lines.

However, since I am not that up to date with OpenCV, and I do not have a VisiCam setup right now, I won't have time to develop it. So if anyone wants to improve VisiCam, this may be an idea.

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.