static void prepare (GeglOperation *operation) { GeglProperties *o = GEGL_PROPERTIES (operation); Priv *p= (Priv*)o->user_data; if (p == NULL) init (o); p = (Priv*)o->user_data; gegl_operation_set_format (operation, "output", babl_format ("R'G'B'A u8")); if (!p->fd) { p->force_format = 1; p->dev_name = o->path; p->io = IO_METHOD_MMAP; p->w = o->width; p->h = o->height; open_device (p); init_device (p); start_capturing (p); } }
/* ============================================================================ * @func KM_OS_init * * @desc This function creates a mem pool. * * @modif None * ============================================================================ */ NORMAL_API DSP_STATUS KM_OS_init( Char8 * strWidth, Char8 * strHeight ) { KM_0Print ("Entered KM_OS_init ()\n") ; DSP_STATUS status = DSP_SOK ; /* Init direct FB */ directfb_init(0, NULL) ; printf("DirectFB initialized\n"); /* Open camera device (/dev/video0) */ if (open_device () == 0) status = DSP_EFAIL ; /* Initialize device */ if (status == DSP_SOK && init_device ( atoi(strWidth), atoi(strHeight) ) == 0) status=DSP_EFAIL ; /* Start capturing */ if (status == DSP_SOK && start_capturing () == 0) status = DSP_EFAIL ; KM_0Print ("Leaving KM_OS_init ()\n") ; return status ; }
void v4l2_init(struct camera *cam) { open_camera(cam); init_camera(cam); start_capturing(cam); init_encoder(cam); init_file(); }
usb_cam_camera_image_t *usb_cam_camera_start(const char* dev, int image_width, int image_height, int framerate, usb_cam_io_method io_method, usb_cam_pixel_format pixel_format) { camera_dev = (char*)calloc(1, strlen(dev) + 1); strcpy(camera_dev, dev); usb_cam_camera_image_t *image; io = io_method; open_device(); init_device(image_width, image_height, framerate); start_capturing(); image = (usb_cam_camera_image_t *)calloc(1, sizeof(usb_cam_camera_image_t)); image->width = image_width; image->height = image_height; image->bytes_per_pixel = 4; image->image_size = image->width * image->height * image->bytes_per_pixel; image->is_new = 0; image->image = (char *)calloc(image->image_size, sizeof(char)); memset(image->image, 0, image->image_size * sizeof(char)); return image; }
/********************************** * V4L2 Wrapper API **********************************/ V4L2WHandler_t * V4L2W_init_w_param(const char * device_name0, struct V4L2W_IMGPARAM imgparam) { V4L2WHandler_t * handle; int outframesize; handle = (V4L2WHandler_t *)malloc(sizeof(struct V4L2W_HANDLER)); handle->dev_name = NULL; handle->io = IO_METHOD_MMAP; handle->fd = -1; handle->buffers = NULL; handle->n_buffers = 0; /* Device name */ strcpy(handle->dev_name_tmp, device_name0); handle->dev_name = handle->dev_name_tmp; /* Device initialization */ handle->imgparam = imgparam; open_device (handle); init_device (handle); start_capturing (handle); /* Allocate Framebuffer */ switch (handle->imgparam.img_fmt) { case V4L2W_IMGFORMAT_GREY: outframesize = handle->imgparam.width * handle->imgparam.height; break; case V4L2W_IMGFORMAT_BGR24: outframesize = handle->imgparam.width * handle->imgparam.height * 3; break; } handle->outimg = malloc(outframesize); return (V4L2WHandler_t *)handle; }
static int alloc(struct vidsrc_st **stp, const struct vidsrc *vs, struct media_ctx **ctx, struct vidsrc_prm *prm, const struct vidsz *size, const char *fmt, const char *dev, vidsrc_frame_h *frameh, vidsrc_error_h *errorh, void *arg) { struct vidsrc_st *st; int err; (void)ctx; (void)prm; (void)fmt; (void)errorh; if (!stp || !size || !frameh) return EINVAL; if (!str_isset(dev)) dev = "/dev/video0"; st = mem_zalloc(sizeof(*st), destructor); if (!st) return ENOMEM; st->vs = vs; st->fd = -1; st->sz = *size; st->frameh = frameh; st->arg = arg; st->pixfmt = 0; err = vd_open(st, dev); if (err) goto out; err = v4l2_init_device(st, dev, size->w, size->h); if (err) goto out; print_video_input(st); err = start_capturing(st); if (err) goto out; st->run = true; err = pthread_create(&st->thread, NULL, read_thread, st); if (err) { st->run = false; goto out; } out: if (err) mem_deref(st); else *stp = st; return err; }
void life_cycle() { fprintf(stderr, "Beginning life cycle\n"); if (!dev_name) { if (vendor >= 0 || product >= 0) { if (vendor < 0 || product < 0) { err("Either give both vendor and product ID or none"); } int dev_id = find_camera(vendor, product); if (dev_id >= 0) { snprintf(dev_name_buf, FULLNAME_MAX_LEN, "/dev/video%d", dev_id); dev_name = &dev_name_buf[0]; } else { err("Could not find device"); } } else { dev_name = "/dev/video0"; } } fprintf(stderr, "Using device %s\n", dev_name); open_device(); init_device(); start_capturing(); mainloop(); stop_capturing(); uninit_device(); close_device(); fprintf(stderr, "Finishing life cycle\n"); }
static int v4l2_case_take_pic(void* user_ptr, int test_num) { FUNC_ENTER() BLTS_DEBUG("Test number %i:\n", test_num); v4l2_data* data = (v4l2_data*)user_ptr; if(!open_device (data->device)) { BLTS_ERROR("Can't open device %s\n", data->device->dev_name); return -1; } if(init_device (data->device, data->device->requested_format.fmt.pix.width, data->device->requested_format.fmt.pix.height)) { if(data->snapshot_filename != NULL) { free(data->snapshot_filename); data->snapshot_filename = NULL; } data->snapshot_filename = create_picture_filename(data->device); BLTS_DEBUG("Filename to create: '%s'\n", data->snapshot_filename); BLTS_DEBUG("Maximum resolution is: %ix%i\n", data->device->format.fmt.pix.width, data->device->format.fmt.pix.height); if(!start_capturing (data->device)) goto err; if(!mainloop (data->device, 0)) goto err; BLTS_DEBUG("Taking picture %s\n", data->snapshot_filename); if(!do_snapshot (data->device, data->snapshot_filename)) goto err; // ensure that image is actual JPEG if(read_jpeg_image(data->snapshot_filename)) { BLTS_DEBUG("Error, image %s is not JPEG standard.\n", data->snapshot_filename); return -1; } stop_capturing (data->device); uninit_device (data->device); } else { BLTS_ERROR("Can't initialize device\n"); goto err; } close_device (data->device); FUNC_LEAVE() return 0; err: stop_capturing(data->device); uninit_device(data->device); close_device(data->device); FUNC_LEAVE() return -1; }
//set all up bool ImgCap_V4L2::openConnection() { if(!init_device(&dev_name, &r_fd, &r_buffers, &r_n_buffers, "right")) {return false;} cameraOn = true; start_capturing(&r_fd, &r_n_buffers); return true; }
int main(int argc, char **argv) { int ret = 0; #ifdef TEST_CONTROLS if (argc != 8) { printf ("%s width height num_of_frames bright contrast saturation sharpness\n", argv[0]); printf("EX) $ %s 640 480 3 0 0 0 24612 \n", argv[0]); goto err; } #else if (argc != 4) { printf ("%s width height num_of_frames bright contrast saturation sharpness\n", argv[0]); printf("EX) $ %s 640 480 3\n", argv[0]); goto err; } #endif g_pix_width = atoi(argv[1]); g_pix_height = atoi(argv[2]); g_file_count = atoi(argv[3]) + 1; #ifdef TEST_CONTROLS g_brightness = atoi(argv[4]); g_contrast = atoi(argv[5]); g_saturation = atoi(argv[6]); g_sharpness = atoi(argv[7]); #endif g_img_buf = malloc(g_pix_width * g_pix_height * 3 * sizeof(char)); open_device(); set_input_chann(0); init_v4l2_device(); ret = init_mmap(&n_buffers); if (ret) errno_exit("init_mmap error !!!"); #ifdef TEST_CONTROLS start_control_testing(); #endif start_capturing(buffers); mainloop(); stop_capturing(); close_mmap(); close_device(); free(g_img_buf); exit(EXIT_SUCCESS); err: return ret; }
int video_specific_init() { video.dev_name = "/dev/video0"; open_device (); init_device (); start_capturing (); capture(); return 0; }
bool Camera::OpenDevice(){ if (open_device()) { printf("open success\n"); if (init_device()) { if (start_capturing()) return true; } } else printf("open failed\n"); return false; }
static int v4l2_run_stream(v4l2_data *data, int do_crop) { int loops = 50; int screen_height = SCREEN_WIDTH; int screen_width = SCREEN_HEIGHT; if (!open_device(data->device)) { BLTS_DEBUG("Can't open device %s\n", data->device->dev_name); return -1; } data->device->use_streaming = 1; if (init_device(data->device, screen_width, screen_height)) { int w = data->device->format.fmt.pix.width; int h = data->device->format.fmt.pix.height; xvideo_init(w, h, 0); if (!start_capturing(data->device)) goto err; if (do_crop) { if (!crop_corners(data->device, loops)) goto err; } else { if (!stream_image_xv(data->device, loops)) goto err; } stop_capturing(data->device); uninit_device(data->device); } else { close_device(data->device); BLTS_DEBUG("Could not open device\n"); data->device->use_streaming = 0; return -1; } data->device->use_streaming = 0; close_device(data->device); xvideo_deinit(); return 0; err: data->device->use_streaming = 0; stop_capturing(data->device); uninit_device(data->device); close_device(data->device); xvideo_deinit(); return -1; }
int main(int argc, char *argv[]) { //strcpy(output_file, argv[1]); open_device(); // ビデオバイスをオープン init_device(); // ビデオデバイスを初期化 start_capturing(); // 画像キャプチャ開始 mainloop(); // メインループ処理 stop_capturing(); // 画像キャプチャ停止 uninit_device(); // 初期化前の状態に戻す close_device(); // ビデオデバイスをクローズ return 0; }
int main() { int fd; fd = open_camer_device(); init_camer_device(fd); start_capturing(fd); mainloop(fd); stop_capturing(fd); uninit_camer_device(fd); close_camer_device(fd); return 0; }
void video_driver::restart_video () { stop_capturing (); uninit_device (); close_device (); open_device (); init_device (); start_capturing (); }
bool v4l_capture::init_all(size_t _width, size_t _height, unsigned int _devId) { width = _width; height = _height; std::ostringstream oss(""); oss << "/dev/video" << _devId; dev_name = oss.str(); if (!open_device()) return false; init_device(); if (!start_capturing()) return false; return true; }
int main() { open_device(); init_device(); init_mmap(); start_capturing(); mainloop(); stop_capturing(); uninit_mmap(); close_device(); return EXIT_SUCCESS; }
void camera_init(int *fd, camera_buffer *camera_buffers, int camera_count){ int i; const char *dev_names[MAX_DEV_COUNT]={"/dev/video0","/dev/video4","/dev/video2","/dev/video3"}; if(camera_count>MAX_DEV_COUNT){ fprintf(stderr,"error: camera_count must equal or less than %d\n",MAX_DEV_COUNT); exit(EXIT_FAILURE); } init_vars(fd,camera_buffers,camera_count); for (i=0;i<camera_count;i++){ open_device(&fd[i],dev_names[i]); init_device(fd[i],&camera_buffers[i],dev_names[i]); start_capturing(fd[i],&camera_buffers[i]); } }
void* startcapture(void* dev) { can_stop = 1; capture* d = get_cap(); dev_name = d->device; wigth = d->weigth; heigth = d->height; open_device(); init_device(); start_capturing(); mainloop(d->refresh); stop_capturing(); uninit_device(); close_device(); return 0; }
/*===========================================================================*/ int pointit_init_cap(int w, int h) { /* TODO: Make this load from a config file */ cam_width = w; cam_height = h; cam_dev_name = "/dev/video0"; /* Make room for an RGB bitmap */ rgb_img = (unsigned char*)malloc(cam_width * cam_height * 3); if (open_device() != 0) return -1; if (init_device() != 0) return -1; if (start_capturing() != 0) return -1; return 0; }
int videodev_start (void) { printf("videocapture: init\n"); dev_name = "/dev/video0"; generate_YCbCr_to_RGB_lookup(); open_device(); if (video_ok == 0) { return 0; } init_device(); if (video_ok == 0) { return 0; } buffer_sdl = (uint8_t*)malloc(WIDTH*HEIGHT*3); data_sf = SDL_CreateRGBSurfaceFrom(buffer_sdl, WIDTH, HEIGHT, 24, WIDTH * 3, mask32(0), mask32(1), mask32(2), 0); start_capturing(); return 0; }
int CameraManager::initializeCamera(int _width, int _height) { width = _width; height = _height; std::cout << "Hej4" << std::endl; open_device(); init_device(); start_capturing(); std::cout << "Hej10" << std::endl; return 0; }
int internal_main( output_callback_func_ptr callback_ptr ) { output = OUTPUT_CALLBACK; output_callback_ptr = callback_ptr; device_open(); init_device(); start_capturing(); capture_loop(); stop_capturing(); uninit_device(); device_close(); return 0; }
//*********************************************************************************** int InitImage() { char buf[20]; static int fd1 = -1; int i,j; io = IO_METHOD_READ; io = IO_METHOD_MMAP; dev_name = VDEVICENAME; open_device (); init_device (); start_capturing (); printf("InitImage success\n"); return 0; }
int main(int argc, char **argv) { dev_name = "/dev/video"; for (;;) { int index; int c; c = getopt_long(argc, argv, short_options, long_options, &index); if (-1 == c) break; switch (c) { case 0: /* getopt_long() flag */ break; case 'd': dev_name = optarg; break; case 'h': usage(stdout, argc, argv); exit(EXIT_SUCCESS); case 'm': io = IO_METHOD_MMAP; break; case 'r': io = IO_METHOD_READ; break; case 'u': io = IO_METHOD_USERPTR; break; default: usage(stderr, argc, argv); exit(EXIT_FAILURE); } } open_device(); init_device(); start_capturing(); mainloop(); stop_capturing(); uninit_device(); close_device(); fputc('\n', stdout); exit(EXIT_SUCCESS); return 0; }
static int test_frame_rate(v4l2_dev_data *dev, float* fps, float* calculated_fps) { int loops = 100; int screen_height = SCREEN_WIDTH; int screen_width = SCREEN_HEIGHT; dev->use_streaming = 1; if (init_device(dev, screen_width, screen_height)) { xvideo_init(dev->format.fmt.pix.width, dev->format.fmt.pix.height, 0); if (!start_capturing(dev)) goto err; if (!stream_image_xv(dev, loops)) goto err; *calculated_fps = dev->calculated_frame_rate; stop_capturing(dev); uninit_device(dev); xvideo_deinit(); } else { close_device(dev); BLTS_DEBUG("Could not open device\n"); dev->use_streaming = 0; return -1; } return 0; err: dev->use_streaming = 0; stop_capturing(dev); uninit_device(dev); xvideo_deinit(); return -1; }
usb_cam_camera_image_t *usb_cam_camera_start( const char* dev, usb_cam_io_method io_method, usb_cam_pixel_format pixel_format, int image_width, int image_height, int framerate) { camera_dev = (char*)calloc(1,strlen(dev)+1); strcpy(camera_dev,dev); usb_cam_camera_image_t *image; io = io_method; if(pixel_format == PIXEL_FORMAT_YUYV) pixelformat = V4L2_PIX_FMT_YUYV; else if(pixel_format == PIXEL_FORMAT_UYVY) pixelformat = V4L2_PIX_FMT_UYVY; else if(pixel_format == PIXEL_FORMAT_MJPEG) { pixelformat = V4L2_PIX_FMT_MJPEG; init_mjpeg_decoder(image_width, image_height); } else { ROS_ERROR("Unknown pixelformat.\n"); return NULL; } open_device(); if (fd == -1) { return NULL; } init_device(image_width, image_height, framerate); start_capturing(); image = (usb_cam_camera_image_t *) calloc(1, sizeof(usb_cam_camera_image_t)); image->width = image_width; image->height = image_height; image->bytes_per_pixel = 24; image->image_size = image->width*image->height*image->bytes_per_pixel; image->is_new = 0; image->image = (char *) calloc(image->image_size, sizeof(char)); memset(image->image, 0, image->image_size*sizeof(char)); return image; }
static int v4l2_case_read_with_poll(void* user_ptr, int test_num) { v4l2_data* data = (v4l2_data*)user_ptr; if (!open_device(data->device)) { BLTS_ERROR("Can't open device %s\n", data->device->dev_name); return -1; } if (!init_device(data->device, data->device->requested_format.fmt.pix.width, data->device->requested_format.fmt.pix.height)) { BLTS_ERROR("Can't initialize device\n"); goto err; } BLTS_DEBUG("Resolution used: %ix%i\n", data->device->format.fmt.pix.width, data->device->format.fmt.pix.height); if (!start_capturing(data->device)) goto err; BLTS_DEBUG("Starting polled reads\n"); if (!mainloop(data->device, LOOPS)) goto err; stop_capturing(data->device); uninit_device(data->device); if (!close_device(data->device)) return -1; return 0; err: stop_capturing(data->device); uninit_device(data->device); close_device(data->device); return -1; }
int main(int argc, char **argv) { dev_name = "/dev/video0"; setpriority(PRIO_PROCESS, 0, -10); generate_YCbCr_to_RGB_lookup(); open_device(); init_device(); atexit(SDL_Quit); if (SDL_Init(SDL_INIT_VIDEO) < 0) return 1; SDL_WM_SetCaption(filter_names[filter_no], NULL); buffer_sdl = (uint8_t*)malloc(WIDTH*HEIGHT*3); SDL_SetVideoMode(WIDTH, HEIGHT, 32, SDL_DOUBLEBUF|SDL_ASYNCBLIT|SDL_HWACCEL|SDL_HWSURFACE); data_sf = SDL_CreateRGBSurfaceFrom(buffer_sdl, WIDTH, HEIGHT, 24, WIDTH * 3, mask32(0), mask32(1), mask32(2), 0); SDL_SetEventFilter(sdl_filter); start_capturing(); mainloop(); stop_capturing(); uninit_device(); close_device(); SDL_FreeSurface(data_sf); free(buffer_sdl); exit(EXIT_SUCCESS); return 0; }