Problems trying to run a sample program
Brought to you by:
aeb,
bencollins
From: Raul M. <mon...@sg...> - 2001-01-25 16:34:11
|
Hi! We have a ieee-1394 connection kit with: -a Sony DFW-VL500 -A Host adapter card 200 Mpbs for PCI bus, Texas Instrument PCILynx compatible. we are for long time trying to run a simple program just to capture an image but in the function: dc1394_single_capture, the program halts (in a read function) and it doesn't continue. We have tested with various kernels, libs version, etc, but it keeps not working. Now, we have 2.2.18 kernel, with the last libraw1394 and libdc1394, (we have obtained it from cvs). The sample program is showed at the end of this message. Is there anybody using the same card and camera (or very similar) that can help us? We want to know: -Kernel version, and which patch. -libraw1394 version -libdc1394 version -A sample program, we want capture only one frame. can Anybody help us? Thanks a lot. The results of testlibraw are: ------------------------------- successfully got handle current generation number: 1 1 card(s) found nodes on bus: 2, card name: pcilynx using first card found: 2 nodes on bus, local ID is 0, IRM is 0 doing transactions with custom tag handler trying to send read request to node 0... completed with 0x00100000, value 0x634b9e50 trying to send read request to node 1... completed with 0x00020000, value 0xc60bcfa1 using standard tag handler and synchronous calls trying to read from node 0... completed with 0x00100000, value 0x83a89e50 trying to read from node 1... failed with error -1100 testing FCP monitoring on local node got fcp command from node 0 of 8 bytes: 01 23 45 67 89 ab cd ef got fcp response from node 0 of 8 bytes: 01 23 45 67 89 ab cd ef polling for leftover messages ----------------------------- What can we test besides testlibraw? ----------------------------- The sample is next: The program prints "mensaje 1" but it doesn't print "mensaje2" ------------------------------ /* * Sample of how to use the 1394-Based Digital Camera Control Library * (libdc1394) * * Written by Chris Urmson <cu...@ri...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <stdio.h> #include <libraw1394/raw1394.h> #include <libdc1394/dc1394_control.h> #include <stdlib.h> /*macro used to convert a YUV pixel to RGB format from Bart Nabbe */ #define YUV2RGB(y, u, v, r, g, b)\ r = y + ((v * 1434) / 2048);\ g = y - ((u * 406) / 2048) - ((v * 595) / 2048);\ b = y + ((u * 2078) / 2048);\ r = r < 0 ? 0 : r;\ g = g < 0 ? 0 : g;\ b = b < 0 ? 0 : b;\ r = r > 255 ? 255 : r;\ g = g > 255 ? 255 : g;\ b = b > 255 ? 255 : b /*routine to convert an array of YUV data to RGB format from Bart Nabbe */ int yuv422torgb (char *YUV, char *RGB, int NumPixels) { int i, j; register int y0, y1, u, v; register int r, g, b; for (i = 0, j = 0; i < 2 * NumPixels; i += 4, j += 6) { u = (unsigned char) YUV[i + 0] - 128; y0 = (unsigned char) YUV[i + 1]; v = (unsigned char) YUV[i + 2] - 128; y1 = (unsigned char) YUV[i + 3]; YUV2RGB (y0, u, v, r, g, b); RGB[j + 0] = r; RGB[j + 1] = g; RGB[j + 2] = b; YUV2RGB (y1, u, v, r, g, b); RGB[j + 3] = r; RGB[j + 4] = g; RGB[j + 5] = b; } return 0; } int main(int argc, char *argv[]) { char *rgb; FILE * imagefile; dc1394_cameracapture camera; int numCameras; raw1394handle_t handle; nodeid_t * camera_nodes; dc1394_feature_set features; /*first we need to get access to the raw1394subsystem*/ handle = dc1394_create_handle(0); if (handle==NULL) { printf("Unable to aquire a raw1394 handle\n"); printf("did you insmod the drivers?\n"); exit(1); } /*get the camera nodes and describe them as we find them*/ camera_nodes = dc1394_get_camera_nodes(handle,&numCameras,1); fflush(stdout); if (numCameras<1) { printf("no cameras found :(\n"); raw1394_destroy_handle(handle); exit(1); } printf("working with the first camera on the bus\n"); /* if (dc1394_setup_camera(handle,camera_nodes[0],0, FORMAT_VGA_NONCOMPRESSED,MODE_320x240_YUV422, SPEED_400,FRAMERATE_7_5,&camera)!=DC1394_SUCCESS) */ if (dc1394_setup_capture(handle,camera_nodes[0],0, FORMAT_VGA_NONCOMPRESSED,MODE_320x240_YUV422, SPEED_400,FRAMERATE_7_5,&camera)!=DC1394_SUCCESS) { printf("unable to setup camera- check line %d of %s to make sure\n", __LINE__,__FILE__); printf("that the video mode,framerate and format are supported\n"); printf("is one supported by your camera\n"); dc1394_release_camera(handle,&camera); raw1394_destroy_handle(handle); exit(1); } if(dc1394_get_camera_feature_set(handle, camera.node,&features) !=DC1394_SUCCESS) { printf("unable to get feature set\n"); } else { dc1394_print_feature_set(&features); } /*have the camera start sending us data*/ if (dc1394_start_iso_transmission(handle,camera.node) !=DC1394_SUCCESS) { printf("unable to start camera iso transmission\n"); dc1394_release_camera(handle,&camera); raw1394_destroy_handle(handle); exit(1); } printf("mensaje 1\n"); if (dc1394_single_capture(handle,&camera)!=DC1394_SUCCESS) // <<<<<<<<<<<<< HERE is the problem { printf("unable to capture a frame\n"); dc1394_release_camera(handle,&camera); raw1394_destroy_handle(handle); exit(1); } printf("mensaje 2\n"); if (dc1394_stop_iso_transmission(handle,camera.node)!=DC1394_SUCCESS) { printf("couldn't stop the camera?\n"); } printf("mensaje 3\n"); /* allocate an RGB buffer that is big enough*/ rgb = (char *)malloc(camera.frame_height*camera.frame_width*3); yuv422torgb((char *)camera.capture_buffer, rgb, camera.frame_height*camera.frame_width); printf("mensaje 4\n"); imagefile=fopen("Image.pgm","w"); fprintf(imagefile,"P6\n%u %u 255\n", camera.frame_width, camera.frame_height ); fwrite(rgb, 1, 3*camera.frame_height*camera.frame_width, imagefile ); fclose(imagefile); printf("wrote: Image.pgm\n"); dc1394_release_camera(handle,&camera); raw1394_destroy_handle(handle); free(rgb); exit(0); } ------------ |