Hi.
Sorry to bother you again but why can NxtCamView capture images within 4 seconds?
How can it read all the lines so fast?
gloomyandy wrote: so each line has to be read in sections (in my case I use 60bytes at a time), thus the 352byte line requires 6 transactions.
why can't you use 75 bytes at a time instead of 60 bytes? (then you only have 5 sections instead of 6 ones)
gloomyandy wrote:One way to reduce some of latency is to use an interleave when grabbing the lines in an attempt to reduce the per line latency and this is possible but it is tricky to get right.
Do you mean changing the transfer order of the lines with "interleaving"?
Why is it so tricky? Do you mean you have to ensure that all lines are transferred finally?
(i.e. without repeating transferring lines which have already been transferred)
That's a mathematical problem, isn't it?
Given we always need 0.0253 seconds to transfer a line, then you miss about 29 lines (0.0253 / 0.0009 = 28.16) while you are transferring one line.
Having transferred line 1, then the next line arriving would be line 30 which you could transfer immediately.
Having transferred line 30, then the next line arriving would be line 59 which you could transfer immediately and so on.
You "only" need to find an easy algorithm with a fixed or flexible line distance (at least 29) so that all lines are transferred finally at all without transferring a line twice.
You get 5 lines per frame (144 / 29 = 4.8 ) so that you need to run over 29 frames (144 / 5 = 28.8 ). This can be done in 4 seconds.
Is that right or do I ignore one important detail by accident?
edit:
I discovered that you can traverse all lines with a line distance of 36 lines with an easy deterministic algorithm.
Have a look on that easy program.
It shows you a sorted set with all numbers between 1 and 144 as entries.
It loses its entries by counting up from 1 to 144 in steps of 36 several times.
So it is counting 1,37,73,109,2,38,74,110,3,39,... .
Every number (or line index) is traversed exactly once.
- Code: Select all
import java.util.SortedSet;
import java.util.TreeSet;
/**
*
* @author Michael Mirwaldt
*
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
SortedSet<Integer> set = new TreeSet<Integer>();
for (int i = 1; i <= 144; i++) {
set.add(i);
}
int index = 1;
final int step = 36;
System.out.println(set);
for (int i = 1; i < 1000 && (set.size()>0); i++) {
System.out.println(i + "->" + index);
set.remove(index);
index+=step;
if(index>144) {
index = index - 143;
}
}
System.out.println(set);
}
}
(the i < 1000 condition is just a protection against an infinite loop.
As you can see, the loop terminates before.)
So you would only need to wait the time of 7 lines (36 - 29 = 7 ) in average instead of the time of 74 lines (0.066 / 0.0009 = 73.3).
This means that the wait time of 9.5 seconds (0.066 * 144) could be decreased to 0.91 seconds (144 * 7 * 0.0009) in total.
Therefore it could maybe be possible to capture an image within 5 seconds with a nxt which is 4 times faster than your first approach.
What a pity I cannot try it out myself unless I have got a nxtcam.
I ordered once some minutes ago.
Will take a week before I get it.
What do you think of that improvement?
Michael