braf78
Messages postés2Date d'inscriptionmardi 18 mars 2008StatutMembreDernière intervention20 mars 2008
-
20 mars 2008 à 12:23
Renfield
Messages postés17287Date d'inscriptionmercredi 2 janvier 2002StatutModérateurDernière intervention27 septembre 2021
-
20 mars 2008 à 15:10
mon probleme quand je compile le grogramme il connait pas fonction de bibliotheque comme (dc1394_cameracapture camera;
raw1394handle_t handle;
nodeid_t * camera_nodes)
merci
-------------------------
#include <stdio.h>
#include
#include
#include <stdlib.h>
#include <string.h>
void setup_camera()
{
int numNodes;
int numCameras;
/* Open ohci and asign handle to it */
handle = dc1394_create_handle(0);
if (handle==NULL)
{
fprintf( stderr, "Unable to aquire a raw1394 handle\n\n"
);
exit(1);
}
/* get the camera nodes and describe them as we find them */
numNodes = raw1394_get_nodecount(handle);
camera_nodes = dc1394_get_camera_nodes(handle,&numCameras,1);
fflush(stdout);
if (numCameras<1)
{
fprintf( stderr, "no cameras found :(\n");
dc1394_destroy_handle(handle);
exit(1);
}
printf("working with the first camera on the bus\n");
if( camera_nodes[0] == numNodes-1)
{
fprintf( stderr, "\n"
"Sorry, your camera is the highest numbered node\n");
dc1394_destroy_handle(handle);
dc1394_free_camera_nodes(camera_nodes);
exit( 1);
}
/*setup capture */
if (dc1394_dma_setup_capture(handle,
camera_nodes[0],
0, /*channel*/
FORMAT_VGA_NONCOMPRESSED,
MODE_640x480_MONO,
SPEED_400,
FRAMERATE_30,
8,
1,
NULL,
&camera) != DC1394_SUCCESS)
{
fprintf( stderr,"unable to setup camera-\n"
"check line %d of %s to make sure\n"
"that the video mode,framerate and format are\n"
"supported by your camera\n",
__LINE__,__FILE__);
dc1394_release_camera(handle,&camera);
dc1394_destroy_handle(handle);
dc1394_free_camera_nodes(camera_nodes);
exit(1);
}
/* have the camera start sending us data*/
if (dc1394_start_iso_transmission(handle,camera.node)
!=DC1394_SUCCESS)
{
fprintf( stderr, "unable to start camera iso transmission\n");
dc1394_release_camera(handle,&camera);
dc1394_destroy_handle(handle);
exit(1);
}
}
void stop_camera()
{
if (dc1394_stop_iso_transmission(handle,camera.node)!=DC1394_SUCCESS)
printf("couldn't stop the camera?\n");
/* Close camera */
dc1394_release_camera(handle,&camera);
dc1394_destroy_handle(handle);
}
int main(int argc, char *argv[])
{
FILE* imagefile;
quadlet_t myq;
/* d'abord initialiser la camera */
setup_camera();
char name[20];
char strnum[5];
int k;
unsigned char * image;
/* capturer quelques frames */
for(k = 1; k < 5; k++) {
dc1394_dma_single_capture(&camera);
//strcpy(name,argv[1]);
strcpy(name,IMAGE_FILE_NAME);
sprintf(strnum,"%04d",k);
strcat(name,strnum);
strcat(name,IMAGE_FILE_EXT);
printf("%s\n",name);
/* (unsigned char *)camera.capture_buffer est un pointer vers l'image
* qu'on a capture */
write_pgm(name,(unsigned char *)camera.capture_buffer,480,640);
image = (unsigned char *)camera.capture_buffer;
/* toujours liberer la frame quand on n'en a plus besoin
*/
dc1394_dma_done_with_buffer(&camera);
}
/*stopper et desalouer la camera */
stop_camera();