Webcam capture - timeout when requesting image - java

I'm using webcam capture to get a webcam image in Java via the following code:
Webcam webcam = Webcam.getWebcamByName("VF0415 Live! Cam Vid. IM Ultra 1"); // USB webcam
webcam.open();
BufferedImage image = webcam.getImage();
ImageIO.write(image, "JPG", new File("test.jpg"));
Unfortunately, I get a timeout with the following error:
[main] INFO com.github.sarxos.webcam.Webcam - WebcamDefaultDriver capture driver will be used
[atomic-processor-1] INFO com.github.sarxos.webcam.ds.cgt.WebcamOpenTask - Opening webcam VF0415 Live! Cam Vid. IM Ultra 1
[frames-refresher-[1]] ERROR com.github.sarxos.webcam.ds.buildin.WebcamDefaultDevice - Timeout when requesting image!
[shutdown-hook-1] INFO com.github.sarxos.webcam.WebcamShutdownHook - Automatic VF0415 Live! Cam Vid. IM Ultra 1 deallocation
[shutdown-hook-1] INFO com.github.sarxos.webcam.Webcam - Disposing webcam VF0415 Live! Cam Vid. IM Ultra 1
[frames-refresher-[1]] ERROR com.github.sarxos.webcam.ds.buildin.WebcamDefaultDevice - Timeout when requesting image!
I've looked through related issues on GitHub, and I've tried keeping my USB power on and intercepting the OS signals, but the error messages remain the same, giving me an essentially black image, as shown here:
Is there anything else I can try to fix this?

Related

android api 30 Fatal signal 6 (SIGABRT)

My app worked fine at api29. Now getting this native error. No clue otherwise.
D/TransportRuntime.SQLiteEventStore: Storing event with priority=DEFAULT, name=FIREPERF for destination cct
V/FA: Connection attempt already in progress
V/FA: Connection attempt already in progress
D/TransportRuntime.JobInfoScheduler: Scheduling upload for context TransportContext(cct, DEFAULT, MSRodHRwczovL2ZpcmViYXNlbG9nZ2luZy1wYS5nb29nbGVhcGlzLmNvbS92MS9maXJlbG9nL2xlZ2FjeS9iYXRjaGxvZ1xBSXphU3lDY2traUg4aTJaQVJ3T3MxTEV6RktsZDE1YU9HOG96S28=) with jobId=-546033166 in 30000ms(Backend next call timestamp 1639520060629). Attempt 1
D/mainact: buildDisplayDataBase:
A/libc: fdsan: attempted to close file descriptor 75, expected to be unowned, actually owned by FILE* 0xf108246c
Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 20661 (eymoreau.fitlog), pid 20661 (eymoreau.fitlog)
Disconnected from the target VM, address: 'localhost:60917', transport: 'socket'
If you are displaying images try eliminating them to see of it fixes the error.
It did for me and I ended up changing my image loading from:
mainMenu_viewHolder.getImageView().setImageResource(R.drawable.gear);
to...
Bitmap checkImg = BitmapFactory.decodeResource(fragment.getResources(), R.drawable.check);
mainMenu_viewHolder.getImageView().setImageBitmap(checkImg);
The issue is buried very deep so if this doesn't work for you don't try stepping through your code or researching the native error. It will be wasted time. Just disable your fragments entire view structure and add back in piece by piece.

Deque Full Exception - Thingsboard

Im having trouble using Thingsboard platform (IoT) when simulating 7.5K devices sending data to the platform. I have the following error in the logs as soon as I start sending data (over MQTT):
2020-08-01 01:17:06,946 [ForkJoinPool-12-worker-0] ERROR c.g.c.u.concurrent.AggregateFuture - Got more than one input Future failure. Logging failures after the first
java.lang.IllegalStateException: Deque full
at java.util.concurrent.LinkedBlockingDeque.addLast(LinkedBlockingDeque.java:335)
at java.util.concurrent.LinkedBlockingDeque.add(LinkedBlockingDeque.java:633)
at org.thingsboard.server.dao.util.AbstractBufferedRateExecutor.submit(AbstractBufferedRateExecutor.java:109)
at org.thingsboard.server.dao.nosql.CassandraAbstractDao.executeAsync(CassandraAbstractDao.java:93)
at org.thingsboard.server.dao.nosql.CassandraAbstractDao.executeAsyncWrite(CassandraAbstractDao.java:76)
at org.thingsboard.server.dao.timeseries.CassandraBaseTimeseriesDao.savePartition(CassandraBaseTimeseriesDao.java:434)
at org.thingsboard.server.dao.timeseries.BaseTimeseriesService.saveAndRegisterFutures(BaseTimeseriesService.java:153)
at org.thingsboard.server.dao.timeseries.BaseTimeseriesService.save(BaseTimeseriesService.java:144)
at org.thingsboard.server.service.telemetry.DefaultTelemetrySubscriptionService.saveAndNotify(DefaultTelemetrySubscriptionService.java:124)
at org.thingsboard.rule.engine.telemetry.TbMsgTimeseriesNode.onMsg(TbMsgTimeseriesNode.java:89)
at org.thingsboard.server.actors.ruleChain.RuleNodeActorMessageProcessor.onRuleChainToRuleNodeMsg(RuleNodeActorMessageProcessor.java:107)
at org.thingsboard.server.actors.ruleChain.RuleNodeActor.onRuleChainToRuleNodeMsg(RuleNodeActor.java:97)
at org.thingsboard.server.actors.ruleChain.RuleNodeActor.doProcess(RuleNodeActor.java:60)
at org.thingsboard.server.actors.service.ContextAwareActor.process(ContextAwareActor.java:45)
at org.thingsboard.server.actors.TbActorMailbox.processMailbox(TbActorMailbox.java:121)
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
I have try to google and see the reason behind it, but i havent found anything.
While simulating with 5K devices, this error came like 3 times each day (over a 4 day period), but it stopped showing that error eventually. However, when increasing the number of devices, the error is constant. Im using Kafka as the broker, but I dont see any Kafka related error. I just want to know why the error appears, is it related to memory, or any other limit?
Thanks in advance
Francisco P

I have error while take screenshot on surface

I have error while take screenshot on surface. After a lot of pictures, this error is made (it comes with the device), but the application does not stop.
After a lot of pictures, this method is no longer working. Do you have an idea about how to solve problems?
#SuppressLint("NewApi")
public static void request(Activity activity, SurfaceView surfaceView, OnScreenShotFinishedListener onScreenShotFinishedListener) {
// Create a bitmap the size of the scene surfaceView.
final Bitmap bitmap = Bitmap.createBitmap(surfaceView.getWidth(), surfaceView.getHeight(), Bitmap.Config.ARGB_8888);
// Create a handler thread to offload the processing of the image.
final HandlerThread handlerThread = new HandlerThread("PixelCopier" + String.valueOf(new Random().nextInt()));
handlerThread.start();
// Make the request to copy.
PixelCopy.request(surfaceView, bitmap, (copyResult) -> {
activity.runOnUiThread(() -> onScreenShotFinishedListener.onScreenShotFinished(copyResult, bitmap));
Log.d("MyData", bitmap.toString());
handlerThread.quitSafely();
handlerThread.interrupt();
}, new Handler(handlerThread.getLooper()));
}
2019-01-29 18:36:07.361 23730-23768/ge.bunny.giffer E/Parcel: dup() failed in Parcel::read, i is 0, fds[i] is -1, fd_count is 2, error: Too many open files
2019-01-29 18:36:07.361 23730-23768/ge.bunny.giffer W/OpenGLRenderer: Failed to get last queued buffer, error = -22
I have seen the same error when using PixelCopy to grab the contents of a SurfaceView continuously (ie. for video transmission). I saw this effect only on Android 7.0 devices.
I attribute this to a memory leak that was present in Readback.cpp which, if I'm not wrong, is what PixelCopy uses internally.
https://github.com/aosp-mirror/platform_frameworks_base/commit/8a29c0ec86a9411a07bb10018c3da69fffc0fe7d#diff-3f79906243073ec92400b65644d330654c8b349e6317259e9639f3a026347d17
This fix was added on September 1st 2016, while Android 7.0 was released August 22nd 2016,

google tango / opencv android camera app crashes/hangs

I am developing a prototype app, utilizing the tango depth camera for template matching. So far, I have been able to solve all problems with the help of already answered questions, documentation etc.
However, now I seem to have come to a stop. Last major change I made, was to draw a contour on the camera preview image, before displaying it. No matter what I do now, the app works for a while, before it crashes.
I have looked at heap dumps and allocation tracking in Android Studio. The only possibly weird thing there is that there can be a lot of memory on FinalizerReference objects in the heap dump...
I also tried moving the processing to an AsyncTask, and just skip every color frame until the task was done (so that only one task was running at a time) and the processed frame was displayed, but the problem remained.
I am using Google Tango for getting color and depth camera data and opencv in java for analyzing the data and doing the template matching.
Does someone have a clue of what these logcat messages mean?
Logcat errors:
E/lowmemorykiller: Error opening /proc/10173/oom_score_adj; errno=2
E/mm-camera-isp2: abf40_trigger_update:587 aec_ratio.ratio = 0.039062
W/ActivityManager: Scheduling restart of crashed service
com.lenovo.lsf.device/com.lenovo.lsf.push.service.PushService in 68068ms
W/ActivityManager: Scheduling restart of crashed service com.qualcomm.qti.modemtestmode/.MbnSystemService in 88020ms
E/InputDispatcher: channel '478a66c com.android.documentsui/com.android.documentsui.DocumentsActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
E/lowmemorykiller: Error writing /proc/10113/oom_score_adj; errno=22
E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 76)
E/lowmemorykiller: Error writing /proc/32408/oom_score_adj; errno=22
E/InputDispatcher: channel '85c4188 com.android.launcher3/com.android.launcher3.Launcher (server)' ~ Channel is unrecoverably broken and will be disposed!
E/mm-camera-isp2: abf40_trigger_update:587 aec_ratio.ratio = 0.000000
E/ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ id=332, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED] ]
E/mm-camera: mct_util_timer_handler:Error Backend stuck during HAL Command Raising SIGABRT
E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 76)
E/lowmemorykiller: Error writing /proc/32437/oom_score_adj; errno=22
E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 308)
E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 76)
E/lowmemorykiller: Error writing /proc/32437/oom_score_adj; errno=22
E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 76)
E/mm-camera: mct_util_timer_handler:Error Backend stuck during HAL Command Raising SIGABRT E/Surface: queueBuffer: error queuing buffer to SurfaceTexture, -32
E/Surface: queueBuffer: error queuing buffer to SurfaceTexture, -32
E/mm-camera: cpp_module_send_buf_divert_event:545] buffer event received with no divert config
E/mm-camera: cpp_module_send_buf_divert_event:545] buffer event received with no divert config
E/Camera3-OutputStream: getBufferLocked: Stream 0: Can't dequeue next output buffer: Broken pipe (-32)
E/Camera3-OutputStream: returnBufferCheckedLocked: Stream 0: Error queueing buffer to native window: Broken pipe (-32)
E/Camera3-Device: RequestThread: Can't get output buffer, skipping request: Broken pipe (-32)
E/Camera3-Device: Can't return buffer to its stream: Broken pipe (-32)
E/Camera3-OutputStream: getBufferLocked: Stream 0: Can't dequeue next output buffer: Broken pipe (-32)
E/Camera3-Device: RequestThread: Can't get output buffer, skipping request: Broken pipe (-32)
Code for displaying camera preview:
mTango.experimentalConnectOnFrameListener(TangoCameraIntrinsics.TANGO_CAMERA_COLOR, new Tango.OnFrameAvailableListener() {
byte[] imageByteArray = new byte[colorCameraIntrinsics.height * colorCameraIntrinsics.width * 3 / 2];
Mat yuvMat = new Mat( colorCameraIntrinsics.height + colorCameraIntrinsics.height/2, colorCameraIntrinsics.width, CvType.CV_8UC1 );
Bitmap bitmapDisplay = Bitmap.createBitmap( colorCameraIntrinsics.width, colorCameraIntrinsics.height, Bitmap.Config.ARGB_8888 );
Mat colorMatDisplay;
#Override
public void onFrameAvailable(TangoImageBuffer imageBuffer, int cameraId) {
Log.d(TAG, "onFrameAvailable: color frame available");
if (colorFrameCounter < 3) { //only use every 3rd frame
Log.d(TAG, "onFrameAvailable: skipping frame " + colorFrameCounter);
colorFrameCounter++;
} else {
colorFrameCounter = 0;
if (!stopCameraView.get()) { // Only view frame if camera view is not stopped
// convert image buffer data to byte array
imageBuffer.data.get(imageByteArray);
// byte array to Mat object with YUV coding (NV21)
yuvMat.put(0, 0, imageByteArray);
// locking access to lastColorFrameMat
synchronized (lockVar) {
Log.d(TAG, "onFrameAvailable: converting to bitmap");
// convert from YUV (NV21) Mat to RGBA Mat and place in lastColorFrameMat (global)
Imgproc.cvtColor(yuvMat, lastColorFrameMat, Imgproc.COLOR_YUV2RGBA_NV21, 4);
colorMatDisplay = lastColorFrameMat.clone();
}
if (templateContours != null) {
Imgproc.drawContours(colorMatDisplay, templateContours, templateContourMaxIdx, new Scalar(0, 255, 0, 255), 5);
}
// convert colorMatDisplay to bitmap, for display in imageview
Utils.matToBitmap(colorMatDisplay, bitmapDisplay);
Log.d(TAG, "onFrameAvailable: view lastColorFrameMat on phone display");
// View colorImage in imageViewer on UI thread
runOnUiThread(new Runnable() {
#Override
public void run() {
imageViewer.setImageBitmap(bitmapDisplay);
}
});
}
}
}
});
There are two things potentially happened here:
the buffer for camera image went out of scope.
With current Tango's SDK, the callee of onFrameAvailable callback only have control to imageBuffer within the scope of the callback. That means if you reference imageBuffer in an AsynTask, you could potentially get a null buffer, and result in a crash. The way Tango solve it is to always deep copy out the data from the callback, and process it in another thread.
the process is blocking Tango's thread for too long.
Without the AsyncTask, what's likely happened is that the processing blocked Tango's thread for too long, and this is know to be bad for Tango as well.

MediaPlayer stops and restarts

I get a weird error.
I play with a MediaPlayer a mediastream (like shoutcast or icecast).
Sometimes suddenly on playing stream (total random) happens a error, the stream stops and restart.
OnErrorListener don't get triggered!
Logcat:
03-02 17:50:36.274: W/MediaPlayer(16799): info/warning (702, 0)
03-02 17:50:36.274: I/MediaPlayer(16799): Info (702,0)
or like this:
03-02 17:50:14.250: W/MediaPlayer(16799): info/warning (703, 0)
03-02 17:50:14.250: W/MediaPlayer(16799): info/warning (701, 0)
03-02 17:50:14.250: I/MediaPlayer(16799): Info (703,0)
03-02 17:50:14.250: I/MediaPlayer(16799): Info (701,0)
or
03-02 18:03:33.906: W/MediaPlayer(16799): info/warning (703, 126) <br>
03-02 18:03:33.906: I/MediaPlayer(16799): Info (703,126)
Any ideas on that?
Edit:
Ahh. One more information. 701 means MEDIA_INFO_BUFFERING_START and 702 means MEDIA_INFO_BUFFERING_END.
I think I could fix these if I increase buffer size?
Edit: But wait. BufferingSize is baked into the system. Damned. :)
As you wrote, buffering...
Sorry, No other suggestions.
It is buffering as you wrote - the only thing I'd like to add is that while it's annoying that it stops or starts, this information is very useful to your user. You may want to update him with a Toast (or a Crouton!) or indicate some sort of buffering status so that they don't blame your app (they will anyway usually!) or so that they know that it's likely their connection to blame - connecting to WIFI in this case is an action that would help.
I'm was seeing the same problem, but it only occurred when using a particular Bluetooth headset and the screen on my phone was off. The app that it occurred in was Just Playlists, a music player that I developed and support.
It only occurred when streaming via Wi-Fi and not via the cell network. I was able to get around the problem by going under Android's advanced Wi-Fi settings and disabling the "Wi-Fi optimization" option, which claims to "minimize battery usage when Wi-Fi is on." I had already used the advanced options to keep Wi-Fi always on.
The headset brand and model are Phiaton PS 210 BTNC. They support Bluetooth 3.0, which makes me suspect this is part of the issue. I've had this problem both under Android 4.1.x and 4.2.2. Here is a log excerpt from when the problem occurs and then recovers:
I/AwesomePlayer( 131): cache is running low (1.90 secs) , pausing.
W/MediaPlayer( 3028): info/warning (703, 0)
W/MediaPlayer( 3028): info/warning (701, 0)
I/MediaPlayer( 3028): Info (703,0)
I/MediaPlayer( 3028): Info (701,0)
I/audio_a2dp_hw( 131): suspend_audio_datapath: state 1
E/bt-btif ( 889): bta_av_str_stopped:audio_open_cnt=1, p_data 586a58f8
W/bt-btif ( 889): bta_dm_rm_cback:1, status:6
W/bt-btif ( 889): bta_dm_rm_cback:1, status:6
I/BluetoothA2dpServiceJni( 889): bta2dp_audio_state_callback
I/audio_a2dp_hw( 131): skt_disconnect: fd 46
D/A2dpStateMachine( 889): Connected process message: 101
D/A2dpStateMachine( 889): A2DP Playing state : device: 00:18:09:06:08:0C State:10->11
I/AwesomePlayer( 131): cache has filled up (6.00 secs), resuming.
I've yet to see what the impact on battery usage is after disabling the Wi-Fi optimization.

Categories

Resources