t-oster / VisiCam

A Java application, that turns a webcam into a VisiCut compatible network camera with marker detection and perspective correction. Uses OpenCV through JavaCV
Other
36 stars 12 forks source link

Capture taking takes a while #7

Open peteruithoven opened 10 years ago

peteruithoven commented 10 years ago

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

t-oster commented 10 years ago

While you're at it: it may be more convenient to try detecting lines (with hough transform), find lines which form a rectangle (of cause a skewed one) and use the corners for the homography, so no markers are necessary. Every laser-bed will be kind of rectangular and if the user can specify regions of interest for the corners it may be enough for robust detection.

peteruithoven commented 10 years ago

"While you're at it... " is quite a pitfall ;) When it works it's easy to improve upon so I would get it working first.

It's also important to check how long each step takes. Maybe it issn't even the opencv step in Java.

peteruithoven commented 10 years ago

Interesting read: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=45758&p=361535 specifying the -t (Time (in ms) before takes picture and shuts down) makes it much faster (default is 5s) Also storing it on RAM memory should make it faster, and it should be better for the SD card. This makes raspistill take 2 seconds instead of 8.

peteruithoven commented 10 years ago

First speed test. Using the following settings:

It outputs the following, the numbers are milliseconds.

start
Taking Snapshot...
snapshot taken: 2851
Finding markers...
  start finding markers: 2855
  found marker: 0: 6287
  start finding markers: 6289
  found marker: 1: 6559
  start finding markers: 6561
  found marker: 2: 6811
  start finding markers: 6813
  found marker: 3: 7081
Found 4/4 markers
Applying transformation...
  CvMat src created: 52
  put markers: 62
  CvMat dst created: 64
  put something else: 67
  CvMat h created: 70
  cvFindHomography: 1085
  created IplImage: 13275
  warped perspecive: 13659
  applied homography: 33983
done: 35397
done

So that means:

t-oster commented 10 years ago

so... next question is how long it takes to apply the homography via a littel C/C++ program.. maybe we can just source this out. Just a litte tool accepting two filenames and 4 coordinate paris via parameters and does the homography...

renebohne commented 9 years ago

We are also having a look at this now.

  1. We are using raspimjpeg for capturing
  2. I am trying to optimize some parts in Java.

My first idea is to buffer the markers, the matrix src, the matrix dst, and the holography h. I created a fork here: https://github.com/renebohne/VisiCam/tree/feature-bufferedHomography

For the Pi Cam, I am also thinking about writing a tool that utilises the gpu... but not sure if homography is something that can be done with the pi gpu... here is a first pointer: http://robotblogging.blogspot.de/2013/10/gpu-accelerated-camera-processing-on.html

peteruithoven commented 9 years ago

Really nice that you guys are looking into this.

FroChr123 commented 9 years ago

Hi, I am currently working on this as well and I try to move some of the stuff to C++ / GPU computations and to use some Raspberry Pi 2 hardware specific acceleration.

@peteruithoven : Which Java version do you use? Just recently I had to reinstall some of the stuff on a Raspberry Pi 2 and there was a notable difference between older and newer Java versions regarding the performance. If I remember correctly, it needed something around 20s on a JDK 6 and it decreased to ~ 8s with a JDK 8.

fabrikationslabor commented 9 years ago

FroChr123 is my student... he writes his bachelor thesis that will add QR Codes to VisiCut. They will be used for two things: physical file sharing and augmented reality markers. For the second part, he will need to make VisiCam as fast as possible (real time!).

FroChr123 commented 9 years ago

The Raspberry Pi 2 / GPU application is located here: https://github.com/FroChr123/visicamRPiGPU

This part should nearly be finished. Of course VisiCam needs to be modified a bit to support it correctly, this will be done in the next few days I think.

Both applications need to work together to use the speed boost of the hardware acceleration. Basically the image capturing and the very slow image processing are outsourced from VisiCam to visicamRPiGPU.

VisiCam: Configuration, networking, marker detection Homography matrix computation based on original image (input for GPU application, every x seconds)

visicamRPiGPU: Capture original image (input for VisiCam -> Homography computation, every x seconds) Compute processed image (input for VisiCam -> Result for network requests)

mgmax commented 8 years ago

Would it be possible to update the wiki page https://github.com/t-oster/VisiCam/wiki/Raspberry-Pi-installation-on-Raspbian and then close this issue?