int camera_get_config_cam_desc (Camera *camera, CameraWidget **window, GPContext *context) { CameraWidget *section; int indw, indr; const CameraDescType *cam_desc = NULL; GP_DEBUG ("*** camera_get_config_cam_desc"); CHECK (camera_start (camera, context)); gp_widget_new (GP_WIDGET_WINDOW, _("Camera Configuration"), window); cam_desc = camera->pl->cam_desc; for (indw = 0; indw < 2 /* XXX sizeof () */; indw++) { GP_DEBUG ("%s registers", cam_desc->regset[indw].window_name); gp_widget_new (GP_WIDGET_SECTION, _(cam_desc->regset[indw].window_name), §ion); gp_widget_append (*window, section); for (indr = 0; indr < cam_desc->regset[indw].reg_cnt; indr++) { camera_cam_desc_get_widget (camera, &cam_desc->regset[indw].regs[indr], section, context); } } return (GP_OK); }
void camera_restart(void) { VideoCircularBuffer *vcb = &video_circular_buffer; pthread_mutex_lock(&vcb->mutex); video_record_stop(vcb); vcb->state = VCB_STATE_RESTARTING; pikrellcam.camera_adjust = camera_adjust_temp; /* May not be changed */ pthread_mutex_unlock(&vcb->mutex); camera_stop(); camera_start(); }
/* Camera initial setup */ void camera_setup () { imgWidth = 320; imgHeight = 256; strcpy1(imgHead, "##IMJ5"); i2cwrite(0x30, ov9655_setup, sizeof(ov9655_setup)>>1); i2cwrite(0x30, ov9655_qvga, sizeof(ov9655_qvga)>>1); camera_init((unsigned char *)DMA_BUF1, (unsigned char *)DMA_BUF2, imgWidth, imgHeight); camera_start(); /* Initialise camera-related globals */ framecount = 0; overlay_flag = 1; quality = 3; // Default JPEG quality. }
void MainWindow::createActions() { openAction = new QAction(tr("&open..."),this); connect(openAction,SIGNAL(triggered()),this,SLOT(open())); saveAction = new QAction(tr("&save..."),this); connect(saveAction,SIGNAL(triggered()),this,SLOT(save())); exitAction = new QAction(tr("&exit"), this); connect(exitAction, SIGNAL(triggered()),this,SLOT(exit())); facedetectAction = new QAction(tr("&Face Detect"),this); connect(facedetectAction, SIGNAL(triggered()),this,SLOT(facedetect())); powertfAction = new QAction(tr("&Power Transform"),this); connect(powertfAction, SIGNAL(triggered()),this,SLOT(powertf())); edgedetectAction = new QAction(tr("&Edge Detect"),this); connect(edgedetectAction, SIGNAL(triggered()),this,SLOT(edgedetect())); houghAction = new QAction(tr("&Hough Check"),this); connect(houghAction, SIGNAL(triggered()), this, SLOT(houghcheck())); morphAction = new QAction(tr("&Morphology"),this); connect(morphAction, SIGNAL(triggered()), this, SLOT(morphology())); blurAction = new QAction(tr("&Blur"),this); connect(blurAction, SIGNAL(triggered()), this, SLOT(bluropt())); histeqAction = new QAction(tr("&Histeq"),this); connect(histeqAction, SIGNAL(triggered()), this, SLOT(histeqopt())); aboutAction = new QAction(tr("&about"),this); connect(aboutAction, SIGNAL(triggered()),this,SLOT(about())); docAction = new QAction(tr("&doc"),this); connect(docAction, SIGNAL(triggered()),this,SLOT(doc())); backwardAction = new QAction(tr("&backward"),this); backwardAction->setIcon(QIcon(":/images/backward.png")); connect(backwardAction,SIGNAL(triggered()), this, SLOT(backward())); forwardAction = new QAction(tr("&forward"),this); forwardAction->setIcon(QIcon(":/images/forward.png")); connect(forwardAction,SIGNAL(triggered()), this, SLOT(forward())); camstartAction = new QAction(tr("&CAM_Start"), this); camstartAction->setIcon(QIcon(":/images/Start.png")); camstartAction->setEnabled(true); connect(camstartAction,SIGNAL(triggered()),this,SLOT(camera_start())); camstopAction = new QAction(tr("&CAM_Stop"), this); camstopAction->setIcon(QIcon(":/images/Stop.png")); camstopAction->setEnabled(false); connect(camstopAction,SIGNAL(triggered()),this,SLOT(camera_stop())); }
// Initialize Camera and Sensors void initDevices(void) { struct pxacam_setting camset; // Backboard uart init fdBackBoard = openSerial(); // 3-axis sensor init fdThreeAxis = open("/dev/MMA_ADC", O_RDONLY); ASSERT(fdThreeAxis); ioctl(fdThreeAxis,MMA_VIN_ON, 0); ioctl(fdThreeAxis,MMA_SLEEP_MODE_ON, 0); ioctl(fdThreeAxis,MMA_SENS_60G, 0); // infrared sensor init fdInfra = open("/dev/FOUR_ADC", O_NOCTTY); ASSERT(fdInfra); // Camera init fdCamera = camera_open(NULL,0); ASSERT(fdCamera); memset(&camset,0,sizeof(camset)); camset.mode = CAM_MODE_VIDEO; camset.format = pxavid_ycbcr422; camset.width = 320; camset.height = 240; camera_config(fdCamera,&camset); camera_start(fdCamera); fdOverlay2 = overlay2_open(NULL,pxavid_ycbcr422,NULL, 320, 240, 0 , 0); overlay2_getbuf(fdOverlay2, &vidbuf_overlay); len_vidbuf = vidbuf_overlay.width * vidbuf_overlay.height; cImg.width=camset.width*2; cImg.height=camset.height; // init finish printf("Initializing Device Finished\n"); }
struct tlv_packet *webcam_start(struct tlv_handler_ctx *ctx) { uint32_t deviceIndex = 0; uint32_t quality = 0; tlv_packet_get_u32(ctx->req, TLV_TYPE_WEBCAM_INTERFACE_ID, &deviceIndex); tlv_packet_get_u32(ctx->req, TLV_TYPE_WEBCAM_QUALITY, &quality); int result = camera_open(deviceIndex - 1); if (result == -1) { return tlv_packet_response_result(ctx, TLV_RESULT_FAILURE); } result = camera_start(); if (result == -1) { return tlv_packet_response_result(ctx, TLV_RESULT_FAILURE); } return tlv_packet_response_result(ctx, TLV_RESULT_SUCCESS); }
int camera_info_init(struct camera * dev) { if(strlen(dev->dev_name) <= 0 ) strncpy(dev->dev_name,"/dev/video100",strlen("/dev/video100")+2); if(dev->v4l_info.wide <= 0 ) dev->v4l_info.wide = 320; if(dev->v4l_info.high <=0 ) dev->v4l_info.high =240; if(dev->v4l_info.v4l_num<=0) dev->v4l_info.v4l_num =4; if(dev->exit==NULL) dev->exit =&camera_exit; if(dev->get_rgb16==NULL) dev->get_rgb16 = &get_rgb16; if(camera_init(dev) <0) return -1; return camera_start(dev) ; }
int camera_set_config_cam_desc (Camera *camera, CameraWidget *window, GPContext *context) { int wind, rind; const CameraDescType *cam_desc = NULL; GP_DEBUG ("*** camera_set_config_cam_desc"); CHECK (camera_start (camera, context)); cam_desc = camera->pl->cam_desc; for (wind = 0; wind < 2 /* XXX sizeof () */; wind++) { GP_DEBUG ("%s registers", cam_desc->regset[wind].window_name); for (rind = 0; rind < cam_desc->regset[wind].reg_cnt; rind++) { camera_cam_desc_set_widget (camera, &cam_desc->regset[wind].regs[rind], window, context); } } return (GP_OK); }
// Initialize Camera and Sensors void initDevices(void) { struct pxacam_setting camset; printf("-----Initializing Device Started-----\n"); // Backboard uart init fdBackBoard = openSerial(); printf("Initializing BackBoard complete!\n"); // 적외선 센서 init fdInfra = open("/dev/FOUR_ADC", O_NOCTTY); // Camera init fdCamera = camera_open(NULL,0); ASSERT(fdCamera); system("echo b > /proc/invert/tb"); //LCD DriverIC top-bottom invert ctrl memset(&camset,0,sizeof(camset)); camset.mode = CAM_MODE_VIDEO; camset.format = pxavid_ycbcr422; camset.width = MAX_X; camset.height = MAX_Y; camera_config(fdCamera,&camset); camera_start(fdCamera); fdOverlay2 = overlay2_open(NULL,pxavid_ycbcr422,NULL, MAX_X, MAX_Y, 0 , 0); overlay2_getbuf(fdOverlay2, &vidbuf_overlay); len_vidbuf = vidbuf_overlay.width * vidbuf_overlay.height; printf("Initializing Camera complete!\n"); // init finish printf("-----Initializing Device Finished-----\n"); }
int main(int argc, char *argv[]) { int fifo; int i, n; char *opt, *arg, *equal_arg, *homedir, *user; char *line, *eol, buf[4096]; pgm_name = argv[0]; bcm_host_init(); time(&pikrellcam.t_now); config_set_defaults(); for (i = 1; i < argc; i++) get_arg_pass1(argv[i]); if (!config_load(pikrellcam.config_file)) config_save(pikrellcam.config_file); if (!motion_regions_config_load(pikrellcam.motion_regions_config_file)) motion_regions_config_save(pikrellcam.motion_regions_config_file); if (!at_commands_config_load(pikrellcam.at_commands_config_file)) at_commands_config_save(pikrellcam.at_commands_config_file); for (i = 1; i < argc; i++) { if (get_arg_pass1(argv[i])) continue; opt = argv[i]; /* Just for initial install-pikrellcam.sh run to create config files. */ if (!strcmp(opt, "-quit")) exit(0); /* Accept: --opt arg -opt arg opt=arg --opt=arg -opt=arg */ for (i = 0; i < 2; ++i) if (*opt == '-') ++opt; if ((equal_arg = strchr(opt, '=')) != NULL) { *equal_arg++ = '\0'; arg = equal_arg; ++i; } else arg = argv[i + 1]; /* For camera parameters, do not set the camera, only replace | values in the parameter table. */ if ( !config_set_option(opt, arg, TRUE) && !mmalcam_config_parameter_set(opt, arg, FALSE) ) { log_printf("Bad arg: %s\n", opt); exit(1); } } homedir = getpwuid(geteuid())->pw_dir; user = strrchr(homedir, '/'); pikrellcam.effective_user = strdup(user ? user + 1 : "pi"); if (*pikrellcam.log_file != '/') { snprintf(buf, sizeof(buf), "%s/%s", pikrellcam.install_dir, pikrellcam.log_file); dup_string(&pikrellcam.log_file, buf); } if (*pikrellcam.media_dir != '/') { snprintf(buf, sizeof(buf), "%s/%s", pikrellcam.install_dir, pikrellcam.media_dir); dup_string(&pikrellcam.media_dir, buf); } strftime(buf, sizeof(buf), "%F %T", localtime(&pikrellcam.t_now)); log_printf("\n%s ==== PiKrellCam started ====\n", buf); snprintf(buf, sizeof(buf), "%s/%s", pikrellcam.install_dir, "www"); check_modes(buf, 0775); asprintf(&pikrellcam.command_fifo, "%s/www/FIFO", pikrellcam.install_dir); asprintf(&pikrellcam.script_dir, "%s/scripts", pikrellcam.install_dir); asprintf(&pikrellcam.mjpeg_filename, "%s/mjpeg.jpg", pikrellcam.mjpeg_dir); log_printf("using FIFO: %s\n", pikrellcam.command_fifo); log_printf("using mjpeg: %s\n", pikrellcam.mjpeg_filename); /* Subdirs must match www/config.php and the init script is supposed | to take care of that. */ asprintf(&pikrellcam.video_dir, "%s/%s", pikrellcam.media_dir, PIKRELLCAM_VIDEO_SUBDIR); asprintf(&pikrellcam.still_dir, "%s/%s", pikrellcam.media_dir, PIKRELLCAM_STILL_SUBDIR); asprintf(&pikrellcam.timelapse_dir, "%s/%s", pikrellcam.media_dir, PIKRELLCAM_TIMELAPSE_SUBDIR); if (!make_dir(pikrellcam.media_dir)) exit(1); snprintf(buf, sizeof(buf), "%s/scripts-dist/init $I $m $M $P $G", pikrellcam.install_dir); exec_wait(buf, NULL); /* User may have enabled a mount disk on media_dir */ exec_wait(pikrellcam.on_startup_cmd, NULL); check_modes(pikrellcam.media_dir, 0775); if ( !make_dir(pikrellcam.mjpeg_dir) || !make_dir(pikrellcam.video_dir) || !make_dir(pikrellcam.still_dir) || !make_dir(pikrellcam.timelapse_dir) || !make_fifo(pikrellcam.command_fifo) ) exit(1); if ((fifo = open(pikrellcam.command_fifo, O_RDONLY | O_NONBLOCK)) < 0) { log_printf("Failed to open FIFO: %s. %m\n", pikrellcam.command_fifo); exit(1); } fcntl(fifo, F_SETFL, 0); read(fifo, buf, sizeof(buf)); sun_times_init(); camera_start(); config_timelapse_load_status(); signal(SIGINT, signal_quit); signal(SIGTERM, signal_quit); signal(SIGCHLD, event_child_signal); while (1) { usleep(1000000 / EVENT_LOOP_FREQUENCY); event_process(); /* Process lines in the FIFO. Single lines via an echo "xxx" > FIFO | or from a web page may not have a terminating \n. | Local scripts may dump multiple \n terminated lines into the FIFO. */ if ((n = read(fifo, buf, sizeof(buf) - 2)) > 0) { if (buf[n - 1] != '\n') buf[n++] = '\n'; /* ensures all lines in buf end in \n */ buf[n] = '\0'; line = buf; eol = strchr(line, '\n'); while (eol > line) { *eol++ = '\0'; command_process(line); while (*eol == '\n') ++eol; line = eol; eol = strchr(line, '\n'); } } } return 0; }
/** * Resume previewing */ static javacall_result camera_resume(javacall_handle handle) { return camera_start(handle); }
int webcam_run() { #ifdef HAVE_CAMERA // Our mandatory renderers, ensures they are run first being registered last struct Node *n = cameras.l_head; while (list_isNode(n)) { CAMERA camera = (CAMERA) n; n = n->n_succ; // Put annotated last list_addTail(&camera->renderers.renderers, &create_annotatedrenderer()->node); // These go first list_addHead(&camera->renderers.renderers, &create_thumbnailrenderer()->node); list_addHead(&camera->renderers.renderers, &create_rawrenderer()->node); } #endif // Now start the system up webserver_initialise(config); #ifdef HAVE_CAMERA // Initialise the renderers n = cameras.l_head; while (list_isNode(n)) { CAMERA camera = (CAMERA) n; n = n->n_succ; imagerenderer_init(camera); } #endif // Initialise the loggers logger_start(); // Finish off configuring the webserver, default port etc webserver_set_defaults(); #ifdef HAVE_CAMERA n = cameras.l_head; while (list_isNode(n)) { CAMERA camera = (CAMERA) n; n = n->n_succ; imagerenderer_postinit(camera); } #endif sensor_postinit(); // The camera home page //create_homepage(); // Start everything up webserver_start(); #ifdef HAVE_CAMERA camera_start(); #endif // Now the main loop, monitor for sensor updates //sensor_loop(); while (1) sleep(60); // Shutdown - we never actually get here webserver_stop(); logger_stop(); #ifdef HAVE_CAMERA camera_stop(); #endif return 0; }
/* camera_new */ Camera * camera_new(GtkWidget * window, GtkAccelGroup * group, char const * device) { Camera * camera; GtkWidget * vbox; GtkWidget * widget; GtkToolItem * toolitem; if((camera = object_new(sizeof(*camera))) == NULL) return NULL; camera->device = (device != NULL) ? string_new(device) : string_new("/dev/video0"); camera->hflip = FALSE; camera->vflip = FALSE; camera->ratio = TRUE; camera->interp = GDK_INTERP_BILINEAR; camera->snapshot_format = CSF_PNG; camera->snapshot_quality = 100; camera->source = 0; camera->fd = -1; memset(&camera->cap, 0, sizeof(camera->cap)); camera->channel = NULL; camera->buffers = NULL; camera->buffers_cnt = 0; camera->raw_buffer = NULL; camera->raw_buffer_cnt = 0; camera->rgb_buffer = NULL; camera->rgb_buffer_cnt = 0; camera->yuv_amp = 255; camera->overlays = NULL; camera->overlays_cnt = 0; camera->widget = NULL; camera->window = window; camera->bold = NULL; camera->gc = NULL; camera->pr_window = NULL; camera->pp_window = NULL; /* check for errors */ if(camera->device == NULL) { camera_delete(camera); return NULL; } /* create the window */ camera->bold = pango_font_description_new(); pango_font_description_set_weight(camera->bold, PANGO_WEIGHT_BOLD); camera->gc = gdk_gc_new(window->window); /* XXX */ #if GTK_CHECK_VERSION(3, 0, 0) camera->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); #else camera->widget = gtk_vbox_new(FALSE, 0); #endif vbox = camera->widget; /* toolbar */ widget = desktop_toolbar_create(_camera_toolbar, camera, group); gtk_widget_set_sensitive(GTK_WIDGET(_camera_toolbar[0].widget), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(_camera_toolbar[2].widget), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(_camera_toolbar[4].widget), FALSE); toolitem = gtk_tool_button_new_from_stock(GTK_STOCK_FULLSCREEN); g_signal_connect_swapped(toolitem, "clicked", G_CALLBACK( _camera_on_fullscreen), camera); gtk_toolbar_insert(GTK_TOOLBAR(widget), toolitem, -1); gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, TRUE, 0); #if GTK_CHECK_VERSION(2, 18, 0) /* infobar */ camera->infobar = gtk_info_bar_new_with_buttons(GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); gtk_info_bar_set_message_type(GTK_INFO_BAR(camera->infobar), GTK_MESSAGE_ERROR); g_signal_connect(camera->infobar, "close", G_CALLBACK(gtk_widget_hide), NULL); g_signal_connect(camera->infobar, "response", G_CALLBACK( gtk_widget_hide), NULL); widget = gtk_info_bar_get_content_area(GTK_INFO_BAR(camera->infobar)); camera->infobar_label = gtk_label_new(NULL); gtk_widget_show(camera->infobar_label); gtk_box_pack_start(GTK_BOX(widget), camera->infobar_label, TRUE, TRUE, 0); gtk_widget_set_no_show_all(camera->infobar, TRUE); gtk_box_pack_start(GTK_BOX(vbox), camera->infobar, FALSE, TRUE, 0); #endif camera->area = gtk_drawing_area_new(); camera->pixmap = NULL; g_signal_connect(camera->area, "configure-event", G_CALLBACK( _camera_on_drawing_area_configure), camera); g_signal_connect(camera->area, "expose-event", G_CALLBACK( _camera_on_drawing_area_expose), camera); gtk_box_pack_start(GTK_BOX(vbox), camera->area, TRUE, TRUE, 0); gtk_widget_show_all(vbox); camera_start(camera); return camera; }