Closed PhilAndrew closed 8 years ago
Hi,
Thanks for your feedback; I'm sorry to hear that it doesn't work for you on Windows (10, but maybe not limited to 10). The first error is concerning, because it says that .start()
might not have been called which is impossible since it is called here, so the error is likely a red herring for something else that has gone wrong in a totally unexpected manner.
I'm glad to see you got your own version working, but it looks like your project is completely different from this project, which makes it hard to pin down where things went haywire. In particular, it seems like you've changed the project definition (you aren't using the sbt-opencv
plugin) and the application code (as you mentioned, not using Akka).
Is it possible for you to try either one of the following and report back?
sbt-opencv
) in this project and see if the application works? If so, this likely means sbt-opencv
isn't pulling in dependencies properly on your OS.sbt-opencv
plugin in your project definition (instead of your own code) and see if it still works? If so, this likely means that the application code in this project somehow isn't compatible with your OS.Since I don't have access to Windows, I would really appreciate your help in narrowing down the problem.
Thanks!
Oh, one more thing, in a project that uses the sbt-opencv
plugin (e.g. the unmodified version of this project), can you run inspect javaCppPlatform
in your SBT console and let me know what it shows? For example:
> inspect javaCppPlatform
[info] Setting: java.lang.String = macosx-x86_64
[info] Description:
[info] The platform that you want to compile for (defaults to the platform of the current computer). You can also set this via the "sbt.javacpp.platform" System Property
[info] Provided by:
[info] {file:/Users/Lloyd/Documents/scala_dev/scala-cv-part1/}scala-cv-part1/*:javaCppPlatform
[info] Defined at:
[info] (com.beachape.sbt.javacpp.Plugin) Plugin.scala:14
[info] Reverse dependencies:
[info] *:libraryDependencies
[info] Delegates:
[info] *:javaCppPlatform
[info] {.}/*:javaCppPlatform
[info] */*:javaCppPlatform
Yes I will spend time on this tomorrow, I want to use your code to fetch data from the webcam.
My example is working now (wrong colors but OK BGR wrong) after exploring different options and it now uses your JavaCV plugin.
https://github.com/PhilAndrew/ScalaOpenCVCameraWhichWorks
Firstly a simple upgrade to OpenCV 3 didn't work as shown here in this branch.
https://github.com/PhilAndrew/ScalaOpenCVCameraWhichWorks/tree/opencv3
So also using your plugin also didn't work as well with that branches code...
I found code from here which works with OpenCV 3 http://answers.opencv.org/question/46638/java-how-capture-webcam-and-show-it-in-a-jpanel-like-imshow/
Then I integrated that in to master branch.
In answer to your question,
> inspect javaCppPlatform
[info] Setting: java.lang.String = windows-x86_64
[info] Description:
[info] The platform that you want to compile for (defaults to the platform of t
he current computer). You can also set this via the "sbt.javacpp.platform" Syste
m Property
[info] Provided by:
[info] {file:/C:/home/projects/blog-scala-javacv-master/}blog-scala-javacv-mast
er/*:javaCppPlatform
[info] Defined at:
[info] (com.beachape.sbt.javacpp.Plugin) Plugin.scala:14
[info] Reverse dependencies:
[info] *:libraryDependencies
[info] Delegates:
[info] *:javaCppPlatform
[info] {.}/*:javaCppPlatform
[info] */*:javaCppPlatform
>
So from the above I don't see any problem with your OpenCV sbt plugin. I have some working code as shown in master branch using your OpenCV sbt plugin. The next step which I have not done is to adapt your Akka project to work as in the same way as my project.
I will try to adapt your Akka code tomorrow as its getting late here. Maybe this indicates a bug in JavaCV for OpenCV 3 using the API your using to fetch video data.
@PhilAndrew thanks for reporting back. This is interesting; you definitely seem to be on to something here.
I found this SO question which suggested that for cross-platform purposes, it may be best to use FrameGrabber.createDefault(0)
instead, so I've updated the code in this project to use that as well. Maybe it will work for you now as well?
Tried your suggestion of createDefault(0), did not work.
Here is a version of your project which works with val g = new VideoCapture(0) which means it works on my windows 10 machine. https://github.com/PhilAndrew/scala-akka-cv-part1/tree/windows10
For me, that's good enough that it works it satisfy's my requirements for continuing on with my project, however it suggests there is a bug in JavaCV or OpenCV or just the Windows version of either as your code should work fine on Windows 10. I'll file a bug on JavaCV when get time.
For example, this person is trying code which looks like yours and says it doesn't work which may be the same bug.
http://stackoverflow.com/questions/26104756/javacv-opencvframegrabber-doesnt-start
Thanks for making the OpenCV sbt plugin, so useful.
If anyone else who reads this and is using Windows and has the same problem please add comments?
@PhilAndrew interesting find! Also, thanks for filling the bug on JavaCV; I've promptly subscribed to that issue.
@PhilAndrew from the other discussion, it looks like there is a regression on the JavaCV side of things that prevents OpenCVFrameGrabber from working, but for now, I've added videoinput
as a preset to be included by default, which should allow FrameGrabber.createDefault to work; the latest version of sbt-opencv
will have it included, and the latest version of this project uses that, so hopefully it will now run on your machine.
Great! I git clone'ed your code and it works now. Solved the problem and it displays the webcam without problem, good work.
[info] Done updating.
[info] Compiling 5 Scala sources to C:\home\projects\git\scala-akka-cv-part1\tar
get\scala-2.11\classes...
[info] Running com.beachape.WebcamWindow
[info]
[info] VIDEOINPUT SPY MODE!
[info]
[info] SETUP: Looking For Capture Devices
[info] SETUP: 0) J1455
[info] SETUP: 1 Device(s) found
[info]
[info]
[info] ***** VIDEOINPUT LIBRARY - 0.2000 - TFW2013 *****
[info]
[info] SETUP: Setting up device 0
[info] SETUP: J1455
[info] SETUP: Couldn't find preview pin using SmartTee
[info] SETUP: Default Format is set to 1280 by 720
[info] SETUP: trying requested format RGB24 @ 640 by 480
[info] SETUP: trying format RGB24 @ 640 by 480
[info] SETUP: trying format RGB32 @ 640 by 480
[info] SETUP: trying format RGB555 @ 640 by 480
[info] SETUP: trying format RGB565 @ 640 by 480
[info] SETUP: trying format YUY2 @ 640 by 480
[info] SETUP: trying format YVYU @ 640 by 480
[info] SETUP: trying format YUYV @ 640 by 480
[info] SETUP: trying format IYUV @ 640 by 480
[info] SETUP: trying format UYVY @ 640 by 480
[info] SETUP: trying format YV12 @ 640 by 480
[info] SETUP: trying format YVU9 @ 640 by 480
[info] SETUP: trying format Y411 @ 640 by 480
[info] SETUP: trying format Y41P @ 640 by 480
[info] SETUP: trying format Y211 @ 640 by 480
[info] SETUP: trying format AYUV @ 640 by 480
[info] SETUP: trying format Y800 @ 640 by 480
[info] SETUP: trying format Y8 @ 640 by 480
[info] SETUP: trying format GREY @ 640 by 480
[info] SETUP: trying format OTHER @ 640 by 480
[info] SETUP: Capture callback set
[info] SETUP: Device is setup and ready to capture.
[info]
[success] Total time: 18 s, completed Mar 19, 2016 9:39:06 AM
c:\home\projects\git\scala-akka-cv-part1>
Hi there, I'm on Windows 10.
Try your code and for me this happens.
Also I made some code which does work for me on my Windows 10, but this code is not using the Akka, just using webcam. https://github.com/PhilAndrew/ScalaOpenCVCameraWhichWorks
Also I tried to enumerate cameras from your code, pasted into your code as follows but this doesn't work either.
Oh anyway this device enumeration doesn't work in my code either so thats not useful.
My webcam is a SJ4000 SJCAM USB.