Closed LoveraSantiago closed 5 years ago
Connect another SSH session and run this:
sudo vcdbg log msg
And check/post the log.
Also, set log level to DEBUG rather than INFO and have a look.
I have literally taken approximately 1 million picture captures with this library without problem.
You camera is enabled via raspi-config? And you can take a picture using Raspistill?
You camera is enabled via raspi-config? And you can take a picture using Raspistill?
Yes it woks with Raspistill.
Without all the logging I asked you for, it's impossible to say any more.
Connect another SSH session and run this:
sudo vcdbg log msg
And check/post the log.
Also, set log level to DEBUG rather than INFO and have a look.
I have literally taken approximately 1 million picture captures with this library without problem.
I really believe that! But as I said previosly I'm begginer at raspiberry world. Ok. I run this sudo command log and get this:
151204.196: camsubs: Looking for camera 0: i2c_port = 0, led gpio = 134, power enable gpio = 133
151504.936: camsubs: Camera not found
151504.984: camsubs: Looking for camera 0: i2c_port = 0, led gpio = 134, power enable gpio = 133
151805.728: camsubs: Camera not found
151805.778: camsubs: Looking for camera 0: i2c_port = 0, led gpio = 134, power enable gpio = 133
151807.420: camsubs: Camera found OK
151809.880: gpioman: gpioman_get_pin_num: pin CAMERA_LED not defined
The debug logs are this:
[sshexec] Connecting to 192.168.1.30:22
[sshexec] cmd : java -jar catapoo-0.1.7-SNAPSHOT.jar
[sshexec] 19-03-30 23:34:15:238 INFO main catapoo.App:14 - App chamado
[sshexec] 19-03-30 23:34:15:247 DEBUG main catapoo.App:15 - Debug Mode Ligado
[sshexec] 19-03-30 23:34:15:251 INFO main camera.MyCameraApplication:19 - MainMethod chamado
[sshexec] 19-03-30 23:34:15:305 DEBUG main picam.Camera:131 - Camera(configuration=uk.co.caprica.picam.CameraConfiguration@17dca04)
[sshexec] 19-03-30 23:34:15:306 DEBUG main picam.Camera:194 - createEncoder()
[sshexec] 19-03-30 23:34:15:326 DEBUG main picam.MmalUtils:49 - CreateComponent(name=vc.ril.image_encode)
[sshexec] 19-03-30 23:34:16:125 DEBUG main picam.MmalUtils:53 - result=0
[sshexec] 19-03-30 23:34:16:187 DEBUG main picam.MmalUtils:63 - component.name=vc.ril.image_encode
[sshexec] 19-03-30 23:34:16:188 DEBUG main picam.MmalUtils:102 - getPort()
[sshexec] 19-03-30 23:34:16:201 DEBUG main picam.MmalUtils:102 - getPort()
[sshexec] 19-03-30 23:34:16:220 DEBUG main picam.MmalParameterUtils:60 - mmal_port_parameter_set_uint32(id=65561,value=85)
[sshexec] 19-03-30 23:34:16:228 DEBUG main picam.MmalUtils:69 - enableComponent()
[sshexec] 19-03-30 23:34:16:229 DEBUG main picam.MmalUtils:71 - component.name=vc.ril.image_encode
[sshexec] 19-03-30 23:34:16:237 DEBUG main picam.MmalUtils:74 - result=0
[sshexec] 19-03-30 23:34:16:238 DEBUG main picam.Camera:225 - createPicturePool()
[sshexec] 19-03-30 23:34:16:255 DEBUG main picam.Camera:237 - createCamera()
[sshexec] 19-03-30 23:34:16:262 DEBUG main picam.MmalUtils:49 - createComponent(name=vc.ril.camera)
[sshexec] 19-03-30 23:34:16:882 DEBUG main picam.MmalUtils:53 - result=0
[sshexec] 19-03-30 23:34:16:890 DEBUG main picam.MmalUtils:63 - component.name=vc.ril.camera
[sshexec] 19-03-30 23:34:16:902 DEBUG main picam.CameraParameterUtils:77 - setStereoscopicMode(stereoscopicMode=NONE,decimate=false,swapEyes=false)
[sshexec] 19-03-30 23:34:16:907 DEBUG main picam.CameraParameterUtils:321 - getCameraCapturePort()
[sshexec] 19-03-30 23:34:16:923 DEBUG main picam.MmalParameterUtils:46 - mmal_port_parameter_set_int32(id=65552,value=0)
[sshexec] 19-03-30 23:34:16:929 DEBUG main picam.MmalParameterUtils:60 - mmal_port_parameter_set_uint32(id=65591,value=0)
[sshexec] 19-03-30 23:34:16:949 DEBUG main picam.Camera:262 - applyCameraControlConfiguration()
[sshexec] 19-03-30 23:34:16:952 DEBUG main picam.MmalParameterUtils:102 - mmal_port_parameter_set(param=65557)
[sshexec] 19-03-30 23:34:16:955 DEBUG main picam.Camera:281 - result=0
[sshexec] 19-03-30 23:34:16:956 DEBUG main picam.Camera:289 - applyCameraConfiguration()
[sshexec] 19-03-30 23:34:16:957 DEBUG main picam.CameraParameterUtils:91 - setBrightness(brightness=null)
[sshexec] 19-03-30 23:34:16:957 DEBUG main picam.CameraParameterUtils:102 - setContrast(contrast=null)
[sshexec] 19-03-30 23:34:16:958 DEBUG main picam.CameraParameterUtils:113 - setSaturation(saturation=null)
[sshexec] 19-03-30 23:34:16:958 DEBUG main picam.CameraParameterUtils:124 - setSharpness(sharpness=null)
[sshexec] 19-03-30 23:34:16:959 DEBUG main picam.CameraParameterUtils:135 - setVideoStabilisation(videoStabilisation=null)
[sshexec] 19-03-30 23:34:16:960 DEBUG main picam.CameraParameterUtils:143 - setShutterSpeed(shutterSpeed=null)
[sshexec] 19-03-30 23:34:16:961 DEBUG main picam.CameraParameterUtils:151 - setIso(iso=null)
[sshexec] 19-03-30 23:34:16:962 DEBUG main picam.CameraParameterUtils:159 - setExposureMode(exposureMode=null)
[sshexec] 19-03-30 23:34:16:962 DEBUG main picam.CameraParameterUtils:170 - setExposureMeteringMode(exposureMeteringMode=null)
[sshexec] 19-03-30 23:34:16:963 DEBUG main picam.CameraParameterUtils:181 - setExposureCompensation(exposureCompensation=null)
[sshexec] 19-03-30 23:34:16:964 DEBUG main picam.CameraParameterUtils:191 - setDynamicRangeCompressionStrength(dynamicRangeCompressionStrength=null)
[sshexec] 19-03-30 23:34:16:964 DEBUG main picam.CameraParameterUtils:202 - setAutomaticWhiteBalanceMode(automaticWhiteBalanceMode=AUTO)
[sshexec] 19-03-30 23:34:16:967 DEBUG main picam.MmalParameterUtils:102 - mmal_port_parameter_set(param=65541)
[sshexec] 19-03-30 23:34:16:971 DEBUG main picam.CameraParameterUtils:213 - setAutomaticWhiteBalanceGains(redGain=null,blueGain=null)
[sshexec] 19-03-30 23:34:16:971 DEBUG main picam.CameraParameterUtils:233 - setImageEffect(imageEffect=null)
[sshexec] 19-03-30 23:34:16:972 DEBUG main picam.CameraParameterUtils:284 - setColourEffect(enable=null,u=null,v=null)
[sshexec] 19-03-30 23:34:16:973 DEBUG main picam.CameraParameterUtils:244 - setMirror(mirror=null)
[sshexec] 19-03-30 23:34:16:973 DEBUG main picam.CameraParameterUtils:255 - setRotation(rotation=null)
[sshexec] 19-03-30 23:34:16:974 DEBUG main picam.CameraParameterUtils:278 - setCrop(crop=java.awt.geom.Rectangle2D$Float[x=0.0,y=0.0,w=1.0,h=1.0])
[sshexec] 19-03-30 23:34:16:975 DEBUG main picam.CameraParameterUtils:266 - setCrop(x=0.0,y=0.0,width=1.0,height=1.0)
[sshexec] 19-03-30 23:34:16:978 DEBUG main picam.MmalParameterUtils:102 - mmal_port_parameter_set(param=65573)
[sshexec] 19-03-30 23:34:16:981 DEBUG main picam.Camera:312 - applyCameraCapturePortFormat()
[sshexec] 19-03-30 23:34:16:989 DEBUG main picam.Camera:338 - result=0
[sshexec] 19-03-30 23:34:16:990 DEBUG main picam.MmalUtils:69 - enableComponent()
[sshexec] 19-03-30 23:34:16:991 DEBUG main picam.MmalUtils:71 - component.name=vc.ril.camera
[sshexec] 19-03-30 23:34:17:184 DEBUG main picam.MmalUtils:74 - result=0
[sshexec] 19-03-30 23:34:17:185 DEBUG main picam.Camera:346 - connectCameraToEncoder()
[sshexec] 19-03-30 23:34:17:186 DEBUG main picam.MmalUtils:109 - connectPorts()
[sshexec] 19-03-30 23:34:17:201 DEBUG main picam.MmalUtils:112 - result=0
[sshexec] 19-03-30 23:34:17:214 DEBUG main picam.MmalUtils:118 - result=0
[sshexec] 19-03-30 23:34:17:216 DEBUG main picam.Camera:356 - createEncoderBufferCallback()
[sshexec] 19-03-30 23:34:17:221 DEBUG main picam.Camera:364 - enableEncoderOutput()
[sshexec] 19-03-30 23:34:17:237 DEBUG main picam.Camera:367 - result=0
[sshexec] 19-03-30 23:34:17:238 DEBUG main picam.Camera:375 - sendBuffersToEncoder()
[sshexec] 19-03-30 23:34:17:240 DEBUG main picam.Camera:378 - bufferCount=1
[sshexec] 19-03-30 23:34:17:266 DEBUG main picam.Camera:389 - result=0
[sshexec] 19-03-30 23:34:17:267 INFO main picam.Camera:157 - >>> Begin Take Picture >>>
[sshexec] 19-03-30 23:34:17:268 DEBUG main picam.Camera:398 - processCapture()
[sshexec] 19-03-30 23:34:17:269 INFO main picam.Camera:403 - Preparing to capture...
[sshexec] 19-03-30 23:34:17:269 DEBUG main picam.Camera:406 - delay=5
[sshexec] 19-03-30 23:34:17:275 DEBUG main picam.FilePictureCaptureHandler:43 - begin()
[sshexec] 19-03-30 23:34:17:276 DEBUG main picam.Camera:447 - startCapture()
[sshexec] 19-03-30 23:34:17:277 DEBUG main picam.MmalParameterUtils:74 - mmal_port_parameter_set_boolean(id=65553,enable=1)
[sshexec] 19-03-30 23:34:17:283 DEBUG main picam.Camera:450 - result=0
[sshexec] 19-03-30 23:34:17:284 INFO main picam.Camera:456 - Capture started
[sshexec] 19-03-30 23:34:17:285 DEBUG main picam.Camera:427 - wait for capture to complete
Thanks.
Honestly, I don't know. Are you using the latest version of this library? Does it hang there every time you use it? What is your own code doing - is it single-threaded?
This looks similar to another reported issue #9, but nobody ever reported it failing on the first capture.
As a result of #9, you can specify a timeout on the capture which would prevent your permanent hang, the idea being you create a new camera and try again. But if you can't get a single capture, I really have no idea what could be wrong.
On the face of this issue looks like #9 (now superseded by #14), but I would like to know if in your case you fail to get even a single capture working.
For the related issue, I have never seen myself or had it reported that the Pi was completely stuck and needed a power-cycle, so there's a chance your issue is different.
Honestly, I don't know. Are you using the latest version of this library? Does it hang there every time you use it? What is your own code doing - is it single-threaded?
This looks similar to another reported issue #9, but nobody ever reported it failing on the first capture.
As a result of #9, you can specify a timeout on the capture which would prevent your permanent hang, the idea being you create a new camera and try again. But if you can't get a single capture, I really have no idea what could be wrong.
Hi Mark Lee. I added you to my project. It's in beginning yet. So there is not much things. I have this problem with picam version 1.0.0 and 1.1.0. On my project I am not starting any new thread, only using main thread. I will put a timeout as you sugested. Is there anything more that I can do to help?
Again. Thank you for your atention.
Will you please answer this question that I asked above:
Does it fail on the first capture? Or have you been capturing lots of pictures and it eventually stops?
Will you please answer this question that I asked above:
Does it fail on the first capture? Or have you been capturing lots of pictures and it eventually stops?
It fails on the first try. A file is created but cant be oppened. It says that is not data into the file.
I can't believe this would be the problem, but would you please try this:
This is the current code:
try (Camera camera = new Camera(config)) {
camera.takePicture(new FilePictureCaptureHandler(new File("photo.jpg")));
}
Change it to this:
FilePictureCaptureHandler handler = new FilePictureCaptureHandler(new File("photo.jpg"));
try (Camera camera = new Camera(config)) {
camera.takePicture(handler);
}
I have had a few JNA projects with non-obvious object-scoping/garbage-collection issues.
I will be amazed if this fixes the problem, but I'd like to rule it out if you don't mind trying.
I tryed with both ways. And get same situation. I am available for any tests.
I have no idea why it fails for you on the first capture.
I've got over 100k successful captures in a test I'm running right now :-/
I noticed before you were using sshexec, have you tried instead manually launching your app on the Pi?
I suppose you could maybe grab your thread dump when you hang just in case there's anything different in there.
Did switching to picam-2.0.0 make any difference for you?
Hi Caprica. Good night. I tryed with picam 2.0.0 . Unfortunally same problems.
On the first try running with sshexec it doesnt show anymore caprica logs information as before. On the second try running directly on raspberry I got same result, it doent show any caprica logs information. Both stuck and even killing the java process when I make reboot on the raspberry it stops and I need to manually shut down.
I was wondering if in my raspberry It missing something to install... could be?
Another thing that I tried. I've cloned picam project directly on my raspberry and did mvn test on command line. It runs sucessfully. But as I could notice, he only test the FourCCTest.java.
Why others class as BasicTest and StressTest are not in the @Test annotation?
Another question. When you are developing the picam code. Where you develop? On another machine, directly on pi, vm? Can you say please how do you debug?
I'm trying to debug remotly but I get a lots of errors.
You asked a bunch of questions...
The tests you mention are not unit-tests, they are integration tests that must be run on the Pi, because that's where the hardware is of course. For me developing on the Pi itself is just too slow and painful. I develop the Java code on Linux, build it, and copy it over. It's a little awkward but only takes a few seconds when you get into the rhythm. So when I run a build on Linux, I can't have those tests run.
For debugging the Java code, in principle you can connect a remote debugger but I never bothered.
For debugging the native code, gdb, but it's kinda hard to use.
For the JNI version (picam-2) there is much less Java code, so the Java logging is basically useless and I removed it.
Anyway, back to your problem...
The thing about the Pi, it's pretty much supposed to be a standard platform, right? So if the camera capture works for me, it should work for everyone. You are the first person I have had a report from that had their Pi completely lock up when trying a capture. Where it apparently locks up, the only thing the Java code is doing is waiting on a semaphore to be notified by a native callback.
The standard test is: does Raspistill work? You already told me Raspistill did work for you, so I am totally confused as to why this library is not working for you and I am running out of suggestions to help you.
Maybe make sure your software is fully upgraded, the OS, the firmware, everything.
Is there anything unusual/non-standard about your Pi hardware and/or OS?
Also, I don't know but it may be better for you to stick with picam-1 until we get to the bottom of this issue.
But really, I don't know what else to suggest right now.
i think we should talk more specifically. when we report a problem we should also tell:
sudo vcdbg log msg
I'm personally using Java Embedded version builded at my local machine then copied to Raspberry, that way save me a lot of space and JVM is specifically Embedded
./ejdk1.8.0_191/bin/jrecreate.sh \
--dest /tmp/ejdk1.8.0_191 \
--profile compact3 \
--vm client \
--extension locales
@caprica Please create Wiki page and explain there steps above, this will help you receive full information and anytime edit that page and share this link with us.
Could you post the exact code you are running and the exact command-line you are using to start your application? If you are running only the code in the tutorial, is it exactly that code without any modifications?
IMO, you should trying using a "proper" JDK on your Pi at least until you get this working.
Your Java Embedded version might be the culprit.
Edit: Ooops, I didn't see that another name joined the conversation. So @AlexanderShniperson you are saying this does actually work with the embedded version? That's really interesting to know.
@LoveraSantiago please tell me your exact OS and JDK/JVM versions, I have a spare Pi that I could try and set up exactly the same as you, but it might take some time.
@caprica i'm in wait for delivery of my new Raspberry Pi Zero to test your library with Java Embedded. at the moment I have a Raspberry Pi 3 with Java Embedded, will try to test library. at the moment i have success run all of my written programs with Embedded JVM without any problems
@LoveraSantiago please tell me your exact OS and JDK/JVM versions, I have a spare Pi that I could try and set up exactly the same as you, but it might take some time.
Hi @caprica and @AlexanderShniperson Good night
I am using -Raspberry Pi 3 - Model B -Java Version 1.8.0_65 -JAVA_HOME = /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/ -NoirCamera V2 8MP
For the project I make a "fat jar" with all dependencies inside my jar. I running it with java -jar ProjectName
I also validate my Raspistill commands directly in the command line and with this little java project who executes raspitill commands. https://blogs.msdn.microsoft.com/robert_mcmurray/2015/06/12/simple-java-wrapper-class-for-raspistill-on-the-raspberry-pi-2/
You're using the standard Raspbian OS?
I have a Pi 2 Model B and a Pi 3 Model B+, both with their own camera.
All of my testing until today had been on the Pi 2 (with OpenJDK).
Today I tested on the Pi 2 with Oracle's JDK, and on the Pi 3 from scratch (a completely fresh installation).
For the Pi 3, I did this:
java -jar picam-2.0.1.jar 800 600 1.jpg
The output was this:
Environment:
java.home : /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre
java.version : 1.8.0_65
java.runtime.name : Java(TM) SE Runtime Environment
java.runtime.version: 1.8.0_65-b17
java.vm.info : mixed mode
java.vm.name : Java HotSpot(TM) Client VM
java.vm.version : 25.65-b01
os.version : 4.14.98-v7+
/etc/issue : Raspbian GNU/Linux 9 \n \l
Temporarily installed picam native library to /tmp/picam-2.0.0.so
Taking picture... ...success!
This produced a file named "1.jpg" that contained a valid picture.
No error and no lockups.
I ran the same test on my Pi 2 with Oracle's JDK. Same result.
Please try the exact same test with picam-2.0.1 jar when it arrives in Maven Central later today.
I am totally at a loss to explain why Raspistill works for you, but this does not. It makes no sense.
I don't know what else I can do to help you. :-(
You're using the standard Raspbian OS?
Hi @caprica I'm using Raspbian GNU/Linux 9 (Stretch)
Well, I have no idea then. I tested that configuration as you can see above.
Please run the test app I mentioned in an above comment.
If that doesn't work, there must be something different about your environment but I don't know what.
I had the same problem. What I've found out is you need to have a little timeout before you make a first camera.takePicture(...)
call, or add the second parameter - delay in milliseconds.
The example has set 1 second delay. I've tested with 500 milliseconds and it worked fine as well.
But if you need to take pics as fast as possible, make sure the first picture is taken after some time the program is started.
BTW: the delay should be between Camera camera = new Camera(config)
and camera.takePicture(...)
.
There is no reason according to the code that what you've described would make any difference.
In my own tests, I take pictures immediately after creating the camera and instantly one after the other with no delay for hundreds of thousands of pictures without seeing this particular issue.
Very, very rarely I do see a hang described in the other issue #9. I have seen that hang maybe once in 1.5 million pictures taken in my own tests.
But what is described in this issue is different to that described in #9.
Believe me, I'd like to 100% nail all such hangs, but dubious sleeps is not IMO the answer.
The only reason I could think of, and this is just a wild guess, the native code which got copied into temp folder right before the camera is initiated is not yet ready for some reason. I'll investigate more and keep you posted. But the delay was the only way I could get the lib working.
That's an interesting observation.
But the code that copies the native library simply uses Files.copy(src,dest). I'd be very surprised if that wasn't guaranteed to complete properly before the method returned and the native library was loaded.
As far as I can remember, I was using the exact same hardware and software as OP and I did not see this issue. It's all very strange.
Any testing is very welcome!
Maybe I have a better SD card or something, I dunno. :-/
I agree that coping the native file cannot be an issue. But initiating Shared Library could take some time I suppose. I'm not sure how it works, but I'm guessing that in some cases the system cannot load objects or functions from .SO
file fast enough.
I also tried to use a permanent location for the native lib without overwriting to eliminate the process of copying the file, and it gives me the same result.
It could be that my system is slower because I do use an old flash card (2-3 years old). I do have a new one, and I'll try to use that one, and let you know if this makes a difference.
Your feedback and testing is appreciated, thanks.
After some research it looks like indeed maybe Files.copy is not forcing a file-system sync. I might try a different way of copying the file and forcing a sync. Not saying this is the whole story, but it may be part of it.
I made a quick patch here 676103a55d23ef74c5a767e00478831905e78ba7
It might help if the theory advanced above is correct.
As to the other suggestion - if the library is not properly loaded and "ready" immediately by the time System.load() returns, then all bets are off. I just can't believe this would be the case.
Reinstalled everything on a new flash card from scratch, have the same problem. Need delay for the library to work. I'll try your patch later and let you know if it helped.
Actually, just reviewing the entirety of this issue I think OP had this issue before picam started bundling a native library.
Hi
i try to use your library at my project and it looks like i facing the problem
have no idea how to fix that
used ver 2.0.3-SNAPSHOT
builded from scratch
lib version 2.0.2
produce the same problem
java.nio.file.ProviderNotFoundException: Provider "jar" not found
at java.nio.file.FileSystems.newFileSystem(Unknown Source)
at java.nio.file.FileSystems.newFileSystem(Unknown Source)
at uk.co.caprica.picam.PicamNativeLibrary.installLibrary(PicamNativeLibr
ary.java:168)
at uk.co.caprica.picam.PicamNativeLibrary.installTempLibrary(PicamNative
Library.java:83)
at net.orionlab.tankclient.CameraPictureStreamer.<init>(Unknown Source)
What happens if you use the latest release version, not a snapshot version?
lib version 2.0.2
from Maven repo produce the same problem
Also have this exception
java.lang.UnsatisfiedLinkError: uk.co.caprica.picam.Camera.create(Luk/co/caprica/picam/CameraConfiguration;)Z
at uk.co.caprica.picam.Camera.create(Native Method)
at uk.co.caprica.picam.Camera.open(Camera.java:106)
at uk.co.caprica.picam.Camera.<init>(Camera.java:91)
at net.orionlab.tankclient.CameraPictureStreamer$startListening$1.run(Unknown Source)
I'm using proguard, maybe it is produce problems, will try to disable them
Disabled ProGuard didn't make effect
Seems like a different issue than what is being discussed here. The only thing I can think of is the JNI version bundles a pre-built shared library that might be incompatible with your Pi hardware/software combination. But I thought all Pi had the same hardware architecture so it would be OK to bundle a pre-built library.
If the problem is with the JNI version go back to the JNA version. :-/
@caprica
can you please suggest me any steps to diagnose the problem with version 2.0.x
?
i really like idea to use JNI instead of JNA
@AlexanderShniperson probably create a new issue for your problem please. things you can try: build the JNI library yourself on your own Pi and tell picam to use that specifically, and/or; post full hardware/OS details, I'm especially interested in the architecture triplet; also make sure you run the test application bundled with picam and post the results (as described in the github readme for the project)
You can use gcc -dumpmachine to get the triplet
Closing due to lack of activity.
Hi Caprica and folks
I am working with camera. I followed the http://capricasoftware.co.uk/projects/picam/tutorials I am using Noir Camera V2 8mp
While running the "Taking Pictures" example I see the logs of the Camera class:
[main] INFO uk.co.caprica.picam.Camera - >>> Begin Take Picture >>>
[main] INFO uk.co.caprica.picam.Camera - Preparing to capture...
[main] INFO uk.co.caprica.picam.Camera - Capture started
And the process stops. Nothing happens. If I run the program again no log appears.
I also noticed that when trying to turn off my raspberry pi it stays frozen and dont shutdown. When I run this example.
Any tips to help me please. Thanks