Hi again!
2008/7/10 David Moore <dcm@...>:
> Okay, that's making more sense now.
>
> I vaguely recall a problem that comes up with ohci-1.0 might be that the
> first frame of a sequence is dropped due to some problems with the
> packet handling. This might be that problem.
>
> Could you try this:
>
> - capture_setup
> - Call one_shot, wait for the register to return to zero.
> - Call one_shot again.
> - Then, dequeue.
> - capture_stop
>
> My hunch is that it will work in this case because you are getting two
> frames. The first one is discarded but the second should be fine.
Your hunch gave me a test idea, of which the results are...
interesting. The plot thickens: it seems the ohci-1.1 cards aren't
without issues after all.
Moreover, it seems that
- without juju: more than one "set_one_shot" command leaves multiple
buffers to be dequeued
- with juju (any card / format): the same results in at most a single
buffer to be dequeued
(which seems horribly inconsistent to me)
> At least this will give you a workaround. I don't remember if this
> first-packet-loss issue was something that could be fixed in the kernel
> or whether it's intrinsic to some ohci-1.0 cards.
Unfortunately, there seems to be more going on than simply "the first
frame will not arrive". ohci-1.1 cards seem to return a frame
immediately, but subsequent capture always fails.
Test code, and elaborate test results follow hereunder.
Many thanks,
Stefaan
#include <stdio.h>
#include <dc1394/dc1394.h>
#include <assert.h>
int main(int argc, char *argv[])
{
dc1394camera_t *camera;
int i;
dc1394video_mode_t video_mode = 0;
dc1394video_frame_t *frame;
dc1394_t * d;
dc1394camera_list_t * list;
dc1394error_t err;
d = dc1394_new ();
// find camera
err=dc1394_camera_enumerate (d, &list);
assert(err==DC1394_SUCCESS);
assert(list->num != 0);
// allocate camera
camera = dc1394_camera_new (d, list->ids[0].guid);
assert(camera);
dc1394_camera_free_list (list);
#if 1
video_mode = DC1394_VIDEO_MODE_FORMAT7_1;
#else
video_mode = DC1394_VIDEO_MODE_1024x768_MONO8;
video_mode = DC1394_VIDEO_MODE_640x480_MONO8;
#endif
// set mode
err=dc1394_video_set_mode(camera, video_mode);
assert(err==DC1394_SUCCESS);
if (video_mode == DC1394_VIDEO_MODE_FORMAT7_1)
{
err = dc1394_format7_set_roi(camera, DC1394_VIDEO_MODE_FORMAT7_1,
DC1394_COLOR_CODING_MONO8,
DC1394_USE_MAX_AVAIL, // use max packet size
0, 0, // left, top
640, 480); // width, height
assert(err==DC1394_SUCCESS);
}
// setup capture
err=dc1394_capture_setup(camera,8, DC1394_CAPTURE_FLAGS_DEFAULT);
assert(err==DC1394_SUCCESS);
int j;
for (j=0; j!=5; ++j)
{
int x;
for (x=0; x!=2; ++x)
{
printf("Set one shot #%d\n", x);
// set one shot
err=dc1394_video_set_one_shot(camera, DC1394_ON);
assert(err==DC1394_SUCCESS);
// get one shot 20 times with interval
for (i=0;i!=20; ++i)
{
dc1394bool_t is_on;
usleep(20000);
err=dc1394_video_get_one_shot(camera, &is_on);
assert(err==DC1394_SUCCESS);
// printf("One shot read after set: %d\n", is_on);
}
}
// capture one frame
err=dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame);
assert(err==DC1394_SUCCESS);
printf("Took image: %d frames behind\n", frame->frames_behind);
err=dc1394_capture_enqueue(camera, frame);
assert(err==DC1394_SUCCESS);
}
// close camera
dc1394_capture_stop(camera);
dc1394_camera_free(camera);
dc1394_free (d);
return 0;
}
old drivers (ohci-1.1 / ohci-1.0, format7 (other formats untested)):
Set one shot #0
Set one shot #1
Took image: 1 frames behind
Set one shot #0
Set one shot #1
Took image: 2 frames behind
Set one shot #0
Set one shot #1
Took image: 3 frames behind
Set one shot #0
Set one shot #1
Took image: 4 frames behind
Set one shot #0
Set one shot #1
Took image: 5 frames behind
juju, ohci-1.1 and format7:
libdc1394 warning: Warning: iso allocation not implemented yet for
juju drivers, using channel 0...
Set one shot #0
Set one shot #1
Took image: 0 frames behind
Set one shot #0
Set one shot #1
... wait forever (extremely repeatable)
juju, ohci-1.0 (both formats), as well as [ohci-1.1 with non-format7]:
libdc1394 warning: Warning: iso allocation not implemented yet for
juju drivers, using channel 0...
Set one shot #0
Set one shot #1
Took image: 0 frames behind
Set one shot #0
Set one shot #1
Took image: 0 frames behind
Set one shot #0
Set one shot #1
Took image: 0 frames behind
Set one shot #0
Set one shot #1
Took image: 0 frames behind
Set one shot #0
Set one shot #1
Took image: 0 frames behind
finishes successfully
Further tests with polling to see when exactly a frame becomes available:
("No frame" is printed when capture doesn't dequeue any frame)
* format7, juju, ohci-1.0:
libdc1394 warning: Warning: iso allocation not implemented yet for
juju drivers, using channel 0...
Set one shot #0
No frame
Set one shot #1
Took image: 0 frames behind
Set one shot #0
No frame
Set one shot #1
Took image: 0 frames behind
Set one shot #0
No frame
Set one shot #1
Took image: 0 frames behind
Set one shot #0
No frame
Set one shot #1
Took image: 0 frames behind
Set one shot #0
No frame
Set one shot #1
Took image: 0 frames behind
* format7, juju, ohci-1.1:
libdc1394 warning: Warning: iso allocation not implemented yet for
juju drivers, using channel 0...
Set one shot #0
Took image: 0 frames behind
Set one shot #0
No frame
Set one shot #1
No frame
Set one shot #2
No frame
Set one shot #3
No frame
Set one shot #4
No frame
Set one shot #5
No frame
Set one shot #6
No frame
Set one shot #7
... and on and on
* other format, juju, ohci-1.0 / 1.1:
libdc1394 warning: Warning: iso allocation not implemented yet for
juju drivers, using channel 0...
Set one shot #0
Took image: 0 frames behind
Set one shot #0
Took image: 0 frames behind
Set one shot #0
Took image: 0 frames behind
Set one shot #0
Took image: 0 frames behind
Set one shot #0
Took image: 0 frames behind
|