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; }
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; }
void v4l_close (ia_v4l_t* v) { uninit_device (v); close_device (v); ia_free (v); }
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"); }
void CameraClose(int cameraNum) { if (-1 == fd) return; stream_off(); uninit_device(); close_device(); }
int InitCamera(int cameraNum, int w, int h) { read_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; read_buf.memory = V4L2_MEMORY_MMAP; dev_name = "/dev/video"; if (cameraNum == 1) dev_name = "/dev/video0"; if (cameraNum == 2) dev_name = "/dev/video1"; io = IO_METHOD_MMAP; /* leave in case range of operation expanded */ if (0 > open_device()) return -1; if (0 > init_device(w,h)) { close_device(); return -1; } if (0 > stream_on()) { uninit_device(); close_device(); return -1; } return 0; }
/** The Destructor */ OMX_ERRORTYPE omx_videosrc_component_Destructor(OMX_COMPONENTTYPE *openmaxStandComp) { omx_videosrc_component_PrivateType* omx_videosrc_component_Private = openmaxStandComp->pComponentPrivate; OMX_ERRORTYPE err = OMX_ErrorNone; OMX_U32 i; if(omx_videosrc_component_Private->videoSyncSem) { tsem_deinit(omx_videosrc_component_Private->videoSyncSem); free(omx_videosrc_component_Private->videoSyncSem); omx_videosrc_component_Private->videoSyncSem=NULL; } err = uninit_device(omx_videosrc_component_Private); if(omx_videosrc_component_Private->deviceHandle != -1) { if(-1 == close(omx_videosrc_component_Private->deviceHandle)) { DEBUG(DEB_LEV_ERR, "In %s Closing video capture device failed \n",__func__); } omx_videosrc_component_Private->deviceHandle = -1; } /* frees port/s */ if (omx_videosrc_component_Private->ports) { for (i=0; i < omx_videosrc_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts; i++) { if(omx_videosrc_component_Private->ports[i]) omx_videosrc_component_Private->ports[i]->PortDestructor(omx_videosrc_component_Private->ports[i]); } free(omx_videosrc_component_Private->ports); omx_videosrc_component_Private->ports=NULL; } noViderSrcInstance--; DEBUG(DEB_LEV_FUNCTION_NAME,"In %s \n",__func__); return omx_base_source_Destructor(openmaxStandComp); }
void capture_close(capture * cap) { uninit_device(cap); close_device(cap); free(cap); }
void V4L2W_finalize(V4L2WHandler_t * handle) { stop_capturing (handle); uninit_device (handle); close_device (handle); free(handle->outimg); free(handle); }
void camera_uninit(int *fd, camera_buffer *camera_buffers, int camera_count){ int i; for (i=0;i<camera_count;i++){ stop_capturing(fd[i]); uninit_device(&camera_buffers[i]); close_device(&fd[i]); } }
void video_cleanup( IMAGE_CONTEXT *v1, IMAGE_CONTEXT *v2 ) { stop_capturing(); uninit_device(); close_device(); image_destroy( v1 ); image_destroy( v2 ); }
int ExitImage() { stop_capturing(); uninit_device(); close_device(); printf ("ExitImage success\n"); return (0); }
int videodev_stop (void) { printf("videocapture: exit\n"); stop_capturing(); close_device(); uninit_device(); SDL_FreeSurface(data_sf); free(buffer_sdl); 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; }
void video_close() { pthread_cancel(video_thread); stop_capturing(); uninit_device(); close_device(); if(save) fclose(file_fd); }
aa::camera::~camera() { uninit_device(); if(-1 == close(device_fd)) { std::stringstream ss; ss << "Failed to close " << device_name << "."; throw std::runtime_error(ss.str()); } }
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[]) { //strcpy(output_file, argv[1]); open_device(); // ビデオバイスをオープン init_device(); // ビデオデバイスを初期化 start_capturing(); // 画像キャプチャ開始 mainloop(); // メインループ処理 stop_capturing(); // 画像キャプチャ停止 uninit_device(); // 初期化前の状態に戻す close_device(); // ビデオデバイスをクローズ return 0; }
void video_driver::restart_video () { stop_capturing (); uninit_device (); close_device (); open_device (); init_device (); start_capturing (); }
int pointit_destroy_cap(void) { if (stop_capturing() != 0) return -1; if (uninit_device() != 0) return -1; if (close_device() != 0) return -1; #ifdef POINTIT_SDL free_sdl_surf(); #endif free(rgb_img); return 0; }
void stop_camera(int* fd, int* rgb_buffer, int* y_buffer) { stop_capturing(*fd); uninit_device(); close_device(fd); if(rgb_buffer) { free(rgb_buffer); } if(y_buffer) { free(y_buffer); } }
static int v4l2_case_measure_resolution(void* user_ptr, int test_num) { v4l2_data* data = (v4l2_data*)user_ptr; BLTS_DEBUG("Test number %i:\n", test_num); if(!open_device (data->device)) { BLTS_DEBUG("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_DEBUG("Resolution gained: %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, LOOPS)) goto err; stop_capturing (data->device); uninit_device (data->device); } else { BLTS_DEBUG("Can't initialize device\n"); goto err; } close_device (data->device); return 0; err: stop_capturing(data->device); uninit_device(data->device); close_device(data->device); return -1; }
CameraV4L::~CameraV4L() { if (!opened) return; if (capturing) stopCapture(); uninit_device(m_io, m_buffers, m_numBuffers); if (close(m_fd) == -1) { cerr << "Error closing device." << endl; } }
static void destructor(void *arg) { struct vidsrc_st *st = arg; if (st->run) { st->run = false; pthread_join(st->thread, NULL); } stop_capturing(st); uninit_device(st); if (st->fd >= 0) v4l2_close(st->fd); }
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 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; }
void usb_cam_camera_shutdown(void) { stop_capturing(); uninit_device(); close_device(); if (avcodec_context) { avcodec_close(avcodec_context); av_free(avcodec_context); avcodec_context = NULL; } if (avframe_camera) av_free(avframe_camera); avframe_camera = NULL; if (avframe_rgb) av_free(avframe_rgb); avframe_rgb = NULL; }
V4LCapture::~V4LCapture() { if(param.replay_mode) { free(buffers->start); free(buffers); }else{ stop_capturing(); uninit_device(); close_device(); } if(video_rec){ fclose(video_rec); } if(time_rec){ fclose(time_rec); } if(dev_name){ free(dev_name); } };
/* Process messages comming from PicoGui */ void chipslicets_message(u32 message, u32 param, u32 *ret) { TRACEF(">>> chipslicets_message\n"); DPRINTF("message=%d param=%d\n", message, param); if(ret) *ret = 0; switch (message) { case PGDM_INPUT_CALEN: DPRINTF("PGDM_INPUT_CALEN:%d\n", param); inhibited = param!=0; if(inhibited) uninit_device(); else init_device(); } }
static int v4l2_case_test_controls(void* user_ptr, int test_num) { v4l2_data* data = (v4l2_data*)user_ptr; BLTS_DEBUG("Test number %i:\n", test_num); if (!setup_img_save_params(data)) return -1; 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 %s\n", data->device->dev_name); close_device(data->device); return -1; } int res = 0; if (test_num == CORE_TEST_STD_CONTROLS) { BLTS_DEBUG("Starting standard control test\n"); if (!test_std_controls(data)) res = -1; } else if (test_num == CORE_TEST_EXT_CONTROLS) { BLTS_DEBUG("Starting extended control test\n"); if (!test_ext_controls(data)) res = -1; } uninit_device(data->device); close_device(data->device); return res; }