I want to get some suggestions from you guys, particularly
Ytai, on a ioio+camera project I am working on.
What I am trying to do is to let ioio control a list of LEDs,
and take a few image frames after turning on each
LED.
In my current code, I have a program structure like following:
public class Master extends IOIOActivity {
boolean [] ledstatus;
class Looper extends BaseIOIOLooper {
//write pins based on ledstatus[i]
}
class Preview extends SurfaceView implements SurfaceHolder.Callback,
Camera.PreviewCallback {
// set ledstatus[i] based on the onPreviewFrame() callback
}
}
I want to understand what are the delays that
I need to be aware of once I set the ledstatus[]
inside the onPreviewFrame callback.
My understanding to the sample code, ioio has
its own thread. In the loop() function, there is
a Thread.sleep() to set an interval to check the
status. This is certainly one of the sources for
asynchronism.
From the point pin.write(true) is called to
the full intensity of the LED, what other latencies
that I should be expecting? I saw from the Wiki
that OpenAssessory mode has a latency of 1ms,
and bluetooth has much longer latency, were you
referring to this this delay?
My camera frame speed is about 20fps~30fps
depending on size of the preview, so it will
be really nice to reduce all the latency to be
less than 30ms, so I only need to toss out one
frame.
Your feedback is very much appreciated!
Qianqian
hi
I want to get some suggestions from you guys, particularly
Ytai, on a ioio+camera project I am working on.
What I am trying to do is to let ioio control a list of LEDs,
and take a few image frames after turning on each
LED.
In my current code, I have a program structure like following:
public class Master extends IOIOActivity {
boolean [] ledstatus;
class Looper extends BaseIOIOLooper {
//write pins based on ledstatus[i]
}
class Preview extends SurfaceView implements SurfaceHolder.Callback, Camera.PreviewCallback {
// set ledstatus[i] based on the onPreviewFrame() callback
}
}
I want to understand what are the delays that
I need to be aware of once I set the ledstatus[]
inside the onPreviewFrame callback.
My understanding to the sample code, ioio has
its own thread. In the loop() function, there is
a Thread.sleep() to set an interval to check the
status. This is certainly one of the sources for
asynchronism.
From the point pin.write(true) is called to
the full intensity of the LED, what other latencies
that I should be expecting? I saw from the Wiki
that OpenAssessory mode has a latency of 1ms,
and bluetooth has much longer latency, were you
referring to this this delay?
My camera frame speed is about 20fps~30fps
depending on size of the preview, so it will
be really nice to reduce all the latency to be
less than 30ms, so I only need to toss out one
frame.
Your feedback is very much appreciated!
Qianqian
--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To post to this group, send email to ioio-...@googlegroups.com.
To unsubscribe from this group, send email to ioio-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ioio-users?hl=en.
Calling sleep() from within loop() is not a requirement.
Yes. This refers to the time it takes from DigitalOutput.write() is called, and until the pin's voltage changes.
Please note: if you're latency-sensitive and want to control many LEDs all at once, take a look at IOIO.beginBatch() et al. It will give you a lot of performance improvement.
My camera frame speed is about 20fps~30fps
depending on size of the preview, so it will
be really nice to reduce all the latency to be
less than 30ms, so I only need to toss out one
frame.
Your feedback is very much appreciated!
Qianqian
--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To post to this group, send email to ioio-...@googlegroups.com.
To unsubscribe from this group, send email to ioio-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ioio-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To post to this group, send email to ioio-...@googlegroups.com.
To unsubscribe from this group, send email to ioio-users+...@googlegroups.com.
On 03/30/2012 11:55 AM, Ytai Ben-Tsvi wrote:hi YtaiCalling sleep() from within loop() is not a requirement.
I removed the sleep call, and my program suddenly
became very sluggish. The timing between switching
on/off each LED became longer and uneven. It appears
like that thread is hogging the CPU and delays responses
from other threads. I put the sleep back afterward.
good, then OpenAccessory mode is definitely good
Yes. This refers to the time it takes from DigitalOutput.write() is called, and until the pin's voltage changes.
enough for me. If I can control ioio via a USB cable
from my galaxy Epic, does that mean the
OpenAssessory mode is working? should I turn off
USB debugging?
I wasn't clear enough. What I meant is that having a sleep() isn't required. But surely you must need some kind of blocking in your loop() if you don't want it to hog the CPU. This blocking can be wait() until a new camera frame is available for example.
In order to use OpenAccessory:
- Your Android must support it. Not sure whether yours does.
- Your IOIO has to be running app firmware V3.23.
- Your IOIO should preferably be running bootloader V3.03. or otherwise you'd have to disconnect / reconnect USB after IOIO power-up in order to get the connection established.
- Your USB debugging needs to be off.
- You need to build your app in a way that supports it (see here: https://github.com/ytai/ioio/wiki/IOIO-Over-OpenAccessory).
Having that said - my suggestion is: get it working over ADB or BT first... Then see if you need to optimize.
On 03/30/2012 02:28 PM, Ytai Ben-Tsvi wrote:hi YtaiI wasn't clear enough. What I meant is that having a sleep() isn't required. But surely you must need some kind of blocking in your loop() if you don't want it to hog the CPU. This blocking can be wait() until a new camera frame is available for example.
thanks again for the comments. To be honest, I wasn't
aware of the wait/notify mechanism in Java. After
working on this last weekend, I managed to migrate
the thread communication using wait/notify.
In the new code, after pin.write(), I set a delay
by Thread.sleep(X) to account for the latency, then
I synchronize a shared object to inform the camera
to collect images. I found that when the delay "X"
is greater than 250ms to 300ms, my images are
always sync with the LED status.
However, for shorter
X, I can see the random intermediate states where
multiple LEDs are half-way on/off. I believe this is due
to the jitter and latency of BT-based communication.
In order to acquire data in faster speed, I would
like to set up the OpenAccessory mode.
I will definitely read more from your wiki, but here I
In order to use OpenAccessory:
- Your Android must support it. Not sure whether yours does.
- Your IOIO has to be running app firmware V3.23.
- Your IOIO should preferably be running bootloader V3.03. or otherwise you'd have to disconnect / reconnect USB after IOIO power-up in order to get the connection established.
- Your USB debugging needs to be off.
- You need to build your app in a way that supports it (see here: https://github.com/ytai/ioio/wiki/IOIO-Over-OpenAccessory).
Having that said - my suggestion is: get it working over ADB or BT first... Then see if you need to optimize.
have a few quick questions and maybe you can help
me to confirm:
1. my IOIOs were purchased a month ago from
sparkfun, do I still need to upgrade the firmware
and bootloader?
2. I imported the libraries from App-IOIO0311.zip,
I saw IOIOLibAccessory in the project list, it appears
there is no error under my Eclipse+ADT14.0.0. Is
this good enough to run OpenAccessory mode?
If an upgrade is needed, I hope the project can still
be backward compatible with BT mode, as it is much
easier to debug.
This doesn't make sense. The latency shouldn't be as high as that, even over Bluetooth. Something else is going on here.
You probably don't need that. ADB will give you 3-4ms latency. OpenAccessory will improve this to be about 1ms. Shouldn't matter.
thanks
Qianqian
To unsubscribe from this group, send email to ioio-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ioio-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To post to this group, send email to ioio-...@googlegroups.com.
To unsubscribe from this group, send email to ioio-users+unsubscribe@googlegroups.com.
Does this camera project succeed? I'm interested in the same thing taking a video remotely and then sending back to the phone. May I know what type of camera are u using? Thanks!
To view this discussion on the web visit https://groups.google.com/d/msg/ioio-users/-/d5gcw3Enxj8J.
To post to this group, send email to ioio-...@googlegroups.com.
To unsubscribe from this group, send email to ioio-users+...@googlegroups.com.
The code makes sense, but I'm not sure what you trying to achieve exactly.Do you want to turn an LED on so that it turns on just when a frame gets taken? If so, using your approach, the LEDs will turn on AFTER the picture got taken, and you'll be synchronizing them with the next frame.
I don't think there should be much delay between the frame and the callback, since you can see e.g. in the camera app that the preview view is pretty low-latency from real life.
On 04/03/2012 08:37 PM, Ytai Ben-Tsvi wrote:no, I want to turn on an LED, wait and "make sure" itThe code makes sense, but I'm not sure what you trying to achieve exactly.Do you want to turn an LED on so that it turns on just when a frame gets taken? If so, using your approach, the LEDs will turn on AFTER the picture got taken, and you'll be synchronizing them with the next frame.
is on, then take a picture, then next. The difficulty is the
"make sure" part. Currently, the only way for me to be
sure is to wait >250ms, which is not good enough. I was
trying to figure out if the IOIO or the camera is responsible.
It seems so, but the truth is that I don't know
I don't think there should be much delay between the frame and the callback, since you can see e.g. in the camera app that the preview view is pretty low-latency from real life.
if the preview buffer in the callback is indeed
synchronized with the image shown on the screen!
I did try mapping the preview buffer to a 2D
OpenGL texture and display it real-time in a
GLSurfaceView, I definitely notice a delay (1/5~1/4 s)
for the OpenGL layer compared to the camera
preview surface. But I don't know if this delay
is due to the processing time of the GL texture
mapping, or due to the arrival delay of the
preview buffer.
In your earlier email, you mentioned ADB latency
is ~4ms, and OpenAccessory is 1ms. How is ADB
related to Bluetooth?
Sometimes, when I power on
IOIO and run the HelloIOIO example, I do see a
noticeable delay between pressing the button and
the LED turning on, does this tell me anything?
One last question, I did try connecting my cellphone
with IOIO by a USB cable, I was able to run the
HelloIOIO example and my code. But you were
certain that OpenAccessory was not on. Is there
another protocol that enables this communication?
ADB is not related to Bluetooth. ADB works over USB. Bluetooth will have latency in the order of 20ms or so IIRC.
This is probably the time it takes to establish a connection to the IOIO. Does it happen also after the initial connection has been established?
Yes. ADB.
OK, so IIUC, all your IOIO questions are answered, right?