int main() { init_window("Blurcode", 320, 80); CvCapture *capture = init_camera(); IplImage *input = query_frame(capture); AppData data; CvSize size = cvSize(input->width / 2, input->height / 2); create_images(&data, size, 3); CvSize debug_size = cvSize(COLUMNS * size.width, ROWS * size.height); data.debug = cvCreateImage(debug_size, IPL_DEPTH_8U, 3); printf("camera=%dx%d zoomed=%dx%d debug=%dx%d\n", input->width, input->height, size.width, size.height, data.debug->width, data.debug->height); int delay = 100; while ((cvWaitKey(delay) & 255) != 27) { delay = 10; input = query_frame(capture); cvCvtColor(input, input, CV_BGR2RGB); // Horizontal flip (mirror display) cvFlip(input, input, 1); cvResize(input, data.rgb, CV_INTER_AREA); cvSplit(data.rgb, data.red, NULL, NULL, NULL); cvSmooth(data.red, data.red, CV_GAUSSIAN, 3, 3, 0, 0); decode(&data, ANGLE_OF_VIEW, "input trace", NULL, NULL); cvResetImageROI(data.debug); cvCvtColor(data.debug, data.debug, CV_RGB2BGR); cvShowImage("Blurcode", data.debug); } cvReleaseCapture(&capture); cvReleaseImage(&data.debug); release_images(&data); cvDestroyWindow("Blurcode"); return 0; }
void setup_scene_0() { theCamera = init_camera(vector_init(2, 1, 3), vector_init(0, 0.3, 0), vector_init(0, 1, 0), 60, (float) WIDTH / (float) HEIGHT); lights[0].position = vector_init(-200, 170, 300); lights[0].col = vector_init(2, 2, 2); num_lights = 1; object_count = 0; material mat; mat.kd = vector_init(.5, .5, .5); mat.ks = vector_init(.5, .5, .5); mat.shininess = 200; mat.reflect_coef = 0.8; scene[object_count++] = init_sphere(0, 0, 0, .3, mat); mat.kd = vector_init(.9, 0, 0); mat.ks = vector_init(.1, .1, .1); mat.shininess = 500; mat.reflect_coef = 0.5; scene[object_count++] = init_sphere(1, -.05, 0, .15, mat); mat.kd = vector_init(0, 1, 0); mat.ks = vector_init(.0, .0, .0); mat.shininess = 0.01; scene[object_count++] = init_sphere(0, 1, 0, .25, mat); mat.kd = vector_init(0, 0, 0.6); mat.ks = vector_init(.4, .4, .4); mat.shininess = 20; mat.reflect_coef = 0.04; scene[object_count++] = init_sphere(0, -.05, 1, .20, mat); }
void MyGLWidget::paintGL () { // Esborrem el frame-buffer i el depth-buffer glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); init_camera(); // Activem el VAO per a pintar el terra glBindVertexArray (VAO_Terra); modelTransformTerra (); // pintem glDrawArrays(GL_TRIANGLES, 0, 12); // Activem el VAO per a pintar el Patricio glBindVertexArray (VAO_Caps); modelTransformCaps1 (); // Pintem l'escena glDrawArrays(GL_TRIANGLES, 0, caps.faces().size()*3); // Activem el VAO per a pintar el Patricio glBindVertexArray (VAO_Caps2); modelTransformCaps2 (); // Pintem l'escena glDrawArrays(GL_TRIANGLES, 0, caps2.faces().size()*3); glBindVertexArray(0); }
void init_drivers(void) { driver.video_data_own = false; driver.audio_data_own = false; driver.input_data_own = false; #ifdef HAVE_CAMERA driver.camera_data_own = false; #endif #ifdef HAVE_LOCATION driver.location_data_own = false; #endif #ifdef HAVE_OSK driver.osk_data_own = false; #endif #ifdef HAVE_MENU // By default, we want the menu to persist through driver reinits. driver.menu_data_own = true; #endif adjust_system_rates(); g_extern.frame_count = 0; init_video_input(); if (!driver.video_cache_context_ack && g_extern.system.hw_render_callback.context_reset) g_extern.system.hw_render_callback.context_reset(); driver.video_cache_context_ack = false; init_audio(); #ifdef HAVE_CAMERA // Only initialize camera driver if we're ever going to use it. if (g_extern.camera_active) init_camera(); #endif #ifdef HAVE_LOCATION // Only initialize location driver if we're ever going to use it. if (g_extern.location_active) init_location(); #endif #ifdef HAVE_OSK init_osk(); #endif #ifdef HAVE_MENU init_menu(); if (driver.menu && driver.menu_ctx && driver.menu_ctx->context_reset) driver.menu_ctx->context_reset(driver.menu); #endif // Keep non-throttled state as good as possible. if (driver.nonblock_state) driver_set_nonblock_state(driver.nonblock_state); g_extern.system.frame_time_last = 0; }
FirewireVideo::FirewireVideo( unsigned deviceid, dc1394video_mode_t video_mode, dc1394framerate_t framerate, dc1394speed_t iso_speed, int dma_buffers ) :running(false),top(0),left(0) { d = dc1394_new (); if (!d) throw VideoException("Failed to get 1394 bus"); err=dc1394_camera_enumerate (d, &list); if( err != DC1394_SUCCESS ) throw VideoException("Failed to enumerate cameras"); if (list->num == 0) throw VideoException("No cameras found"); if( deviceid >= list->num ) throw VideoException("Invalid camera index"); const uint64_t guid = list->ids[deviceid].guid; dc1394_camera_free_list (list); init_camera(guid,dma_buffers,iso_speed,video_mode,framerate); }
void v4l2_init(struct camera *cam) { open_camera(cam); init_camera(cam); start_capturing(cam); init_encoder(cam); init_file(); }
void RenderSystem::v_Init() { init_device(); init_camera(); m_Triangle.Init(m_pD3D11Device.Get(), m_pD3D11DeviceContext.Get(), GetHwnd() ); }
void RenderSystem::v_Init() { init_device(); init_camera(); init_object(); }
void D3D11Render::v_init() { init_device(); init_camera(); init_object(); sound.Init(); }
void draw_map(t_wf *game) { int x; int color; x = 0; while (x < game->len_m) { game = init_camera(game, x); game = get_dist(game); game = detect_wall(game); game = get_wall_length(game); game->height_m = fabs((int)(game->map_h / game->wall_length)); game->draw_init = -game->height_m / 2 + game->map_h / 2; if (game->draw_init < 0) game->draw_init = 0; game->draw_end = game->height_m / 2 + game->map_h / 2; if (game->draw_end >= game->map_h) game->draw_end = game->map_h - 1; color = ft_color_tab(game); if (game->w_side == 1) color /= 2; draw_line(x, game, color); x++; } return ; }
bool v4l2_init(Camera* cam) { open_camera(cam); init_camera(cam); start_video_capturing(cam); return true ;
int main() { ssc_init("/dev/ttyUSB0", 9600); pan( 0 ); tilt( 0 ); cascade = (CvHaarClassifierCascade*)cvLoad( "cascade.xml", 0, 0, 0 ); if( !cascade ) { fprintf( stderr, "ERROR: Could not load classifier cascade\n" ); return 1; } storage = cvCreateMemStorage(0); struct camera *cam = init_camera( LCAM ); load_params( cam ); cvNamedWindow( "Face", CV_WINDOW_AUTOSIZE ); CvPoint pt1, pt2; CvRect *r; CvSeq *faces; float multip = 0.1; int x_diff, y_diff; while( cvWaitKey( 10 ) == -1 ) { cap_frame( cam ); undistort( cam ); cvClearMemStorage( storage ); faces = cvHaarDetectObjects( cam->undist, cascade, storage, 1.1, 2, CV_HAAR_DO_CANNY_PRUNING, cvSize(40, 40) ); if (faces->total > 0) { ; r = (CvRect*)cvGetSeqElem( faces, 0 ); pt1.x = r->x; pt2.x = r->x + r->width; pt1.y = r->y; pt2.y = r->y + r->height; cvRectangle( cam->undist, pt1, pt2, CV_RGB(255,0,0), 3, 8, 0 ); x_diff = (cam->frame->width / 2) - (r->x + (r->width/2)) ; y_diff = (cam->frame->height / 2) - (r->y + (r->height/2)) ; pan( -(int)(x_diff * multip) ); tilt( (int)(y_diff * multip) ); } cvShowImage( "Face", cam->undist ); } cvDestroyAllWindows(); cvReleaseMemStorage( &storage ); free_camera( cam ); }
int main(int argc, char **argv) { const int usage = SCREEN_USAGE_NATIVE; screen_window_t screen_win; screen_buffer_t screen_buf = NULL; int rect[4] = { 0, 0, 0, 0 }; // create an application window which will just act as a background screen_create_context(&screen_ctx, 0); screen_create_window(&screen_win, screen_ctx); screen_create_window_group(screen_win, vf_group); screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage); screen_create_window_buffers(screen_win, 1); screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf); screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, rect+2); // fill the window with black int attribs[] = { SCREEN_BLIT_COLOR, 0x00000000, SCREEN_BLIT_END }; screen_fill(screen_ctx, screen_buf, attribs); screen_post_window(screen_win, screen_buf, 1, rect, 0); // position the window at an arbitrary z-order int i = APP_ZORDER; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &i); // Signal bps library that navigator and screen events will be requested bps_initialize(); screen_request_events(screen_ctx); navigator_request_events(0); // open camera and configure viewfinder if (init_camera() == EOK) { // our main loop just runs a state machine and handles input while (!shutdown) { run_state_machine(); // Handle user input handle_event(); } if (state == STATE_VIEWFINDER) { // clean up camera camera_stop_photo_viewfinder(handle); camera_close(handle); } } // Clean up screen_stop_events(screen_ctx); bps_shutdown(); screen_destroy_window(screen_win); screen_destroy_context(screen_ctx); return 0; }
void setup_scene_4() { theCamera = init_camera(vector_init(2, 1, 3), vector_init(0, 0.3, 0), vector_init(0, 1, 0), 60, (float) WIDTH / (float) HEIGHT); lights[0].position = vector_init(0, 1.7, 1); lights[0].col = vector_init(1, 1, 1); lights[1].position = vector_init(3, 2, 3); lights[1].col = vector_init(0.4, 0.4, 0.4); lights[2].position = vector_init(4, 3, -1); lights[2].col = vector_init(0.5, 0.5, 0.5); num_lights = 3; object_count = 0; material mat; mat.kd = vector_init(.5, .5, .5); mat.ks = vector_init(.5, .5, .5); mat.shininess = 200; mat.reflect_coef = 0.4; scene[object_count++] = init_sphere(0, 0, 0, .3, mat); mat.kd = vector_init(.9, 0, 0); mat.ks = vector_init(.1, .1, .1); mat.shininess = 500; scene[object_count++] = init_sphere(1, -.05, 0, .15, mat); mat.kd = vector_init(0, 1, 0); mat.ks = vector_init(.0, .0, .0); mat.shininess = 0.01; mat.reflect_coef = 0.04; scene[object_count++] = init_sphere(0, 1, 0, .25, mat); mat.kd = vector_init(0, 0, 0.6); mat.ks = vector_init(.4, .4, .4); mat.shininess = 20; scene[object_count++] = init_sphere(0, -.05, 1, .20, mat); mat.kd = vector_init(.5, 0.9, .7); mat.ks = vector_init(.01, .01, .01); mat.shininess = 100; mat.reflect_coef = 0.04; scene[object_count++] = init_plane(0, 1, 0, 0.2, mat); mat.kd = vector_init(.8, 0.09, .07); mat.ks = vector_init(.2, .2, .1); mat.shininess = 10; mat.reflect_coef = 0.5; scene[object_count++] = init_plane(1, 0.0, -1.0, 2, mat); mat.kd = vector_init(0.1, 0.3, .05); mat.ks = vector_init(.5, .5, .5); mat.shininess = 20; scene[object_count++] = init_plane(0.3, -0.2, 1, 3, mat); }
void RenderSystem::v_Init() { init_device(); init_camera(); m_Timer.Reset(); m_Camera.SetRadius(5.0f); m_Cube.Init(m_pD3D11Device.Get(), m_pD3D11DeviceContext.Get(), GetHwnd() ); m_LightShader.Init(m_pD3D11Device.Get(), m_pD3D11DeviceContext.Get(), GetHwnd()); m_AlphaShader.Init(m_pD3D11Device.Get(), m_pD3D11DeviceContext.Get(), GetHwnd()); }
int main(int argc, char *argv[]) { static struct Camera camera; pthread_t draw_thread, grab_thread, tele_thread; init_camera(&camera); if(argc >= 2 && strcmp(argv[1], "GPS_ON") == 0) camera.gpson = TRUE; //init threads g_thread_init(NULL); gdk_threads_init(); //init gtk gtk_init(&argc, &argv); //Init gdk_rgb gdk_rgb_init(); //Init semaphore sem_init(&sem_draw, 0, 0); sem_init(&sem_grab, 0, 1); open_camera(&camera); set_camera_info(&camera); get_camera_info(&camera); // print_camera_info(&camera); create_window(&camera); if(camera.gpson) { camera_antennaimg_change(&camera, "0"); pthread_create(&tele_thread, NULL, (void*)&camera_gps_tel, &camera); } pthread_create(&draw_thread, NULL, (void*)&preview_camera, &camera); pthread_create(&grab_thread, NULL, (void*)&grab_image_camera, &camera); gdk_threads_enter(); gtk_main(); gdk_threads_leave(); camera.quit = 1; if(camera.gpson) pthread_join(tele_thread, NULL); pthread_join(grab_thread, NULL); pthread_join(draw_thread, NULL); sem_post(&sem_draw); sem_post(&sem_grab); sem_destroy(&sem_draw); sem_destroy(&sem_grab); close_camera(&camera); return 0; }
FirewireVideo::FirewireVideo( Guid guid, dc1394video_mode_t video_mode, dc1394framerate_t framerate, dc1394speed_t iso_speed, int dma_buffers ) :running(false),top(0),left(0) { d = dc1394_new (); if (!d) throw VideoException("Failed to get 1394 bus"); init_camera(guid.guid,dma_buffers,iso_speed,video_mode,framerate); }
void render(t_ray *ray) { ray->x = 0; while (ray->x <= WINDOW_W) { init_camera(ray); ray->mapx = (int)ray->rayposx; ray->mapy = (int)ray->rayposy; raycast1(ray); raycast2(ray); raycast3(ray); draw(ray); ray->x++; } }
void init_drivers(void) { driver.video_data_own = !driver.video_data; driver.audio_data_own = !driver.audio_data; driver.input_data_own = !driver.input_data; #ifdef HAVE_CAMERA driver.camera_data_own = !driver.camera_data; #endif #ifdef HAVE_LOCATION driver.location_data_own = !driver.location_data; #endif #ifdef HAVE_OSK driver.osk_data_own = !driver.osk_data; #endif adjust_system_rates(); g_extern.frame_count = 0; init_video_input(); if (!driver.video_cache_context_ack && g_extern.system.hw_render_callback.context_reset) g_extern.system.hw_render_callback.context_reset(); driver.video_cache_context_ack = false; init_audio(); #ifdef HAVE_CAMERA // Only init camera driver if we're ever going to use it. if (g_extern.camera_active) init_camera(); #endif #ifdef HAVE_LOCATION // Only init location driver if we're ever going to use it. if (g_extern.location_active) init_location(); #endif #ifdef HAVE_OSK init_osk(); #endif // Keep non-throttled state as good as possible. if (driver.nonblock_state) driver_set_nonblock_state(driver.nonblock_state); g_extern.system.frame_time_last = 0; }
/* * Construct and return a new world object. */ struct world_t* world_init() { struct world_t* w = (struct world_t*)malloc(sizeof(struct world_t)); memset(w, 0, sizeof(struct world_t)); w->flags = WORLD_DEFAULT_FLAGS; /* setup the camera */ init_camera(&w->camera); /* setup the environment */ init_env(&w->env); /* setup the main light */ init_light(&w->light[0]); return w; }
//初始化 void START::init(wchar_t *name_snake,wchar_t**name_text,int start,int prompt, const D3DXVECTOR3 &position,const D3DXVECTOR3 &lookat) { init_snake(name_snake); init_camera(position,lookat); init_text(name_text,start,prompt); _init_position = position; _init_target = lookat; //初始化时间 _time_one = _time_one_almost; _time_two = _time_two_almost; _time_three = _time_three_almost; _time_lock = 0; _isrender_start_text = false; _isrender_prompt_text = false; }
void setup_scene_2() { theCamera = init_camera(vector_init(2, 1, 3), vector_init(0, 0.3, 0), vector_init(0, 1, 0), 60, (float) WIDTH / (float) HEIGHT); lights[0].position = vector_init(-2, 1.7, 3); lights[0].col = vector_init(1, 1, 1); lights[1].position = vector_init(3, 2, 3); lights[1].col = vector_init(0.4, 0.4, 0.4); lights[2].position = vector_init(4, 3, -10); lights[2].col = vector_init(0.5, 0.5, 0.5); num_lights = 3; object_count = 0; material mat; mat.shininess = 20; mat.kd = vector_init(1, 1, 1); mat.ks = vector_init(.5, .5, .5); mat.reflect_coef = 0.8; scene[object_count++] = init_sphere(0, 0, 0, .3, mat); mat.reflect_coef = 0.5; mat.shininess = 20; mat.kd = vector_init(0, 0, 1); scene[object_count++] = init_sphere(0, -.05, 1, .20, mat); mat.reflect_coef = 0.04; mat.ks = vector_init(.1, .1, .1); mat.kd = vector_init(0, 1, 0); scene[object_count++] = init_sphere(0, 1, 0, .15, mat); mat.kd = vector_init(1, 0, 0); mat.shininess = 500; scene[object_count++] = init_sphere(1, -.05, 0, .15, mat); mat.kd = vector_init(.5, 1, .7); scene[object_count++] = init_plane(0, 1, 0, 0.2, mat); mat.reflect_coef = 0.0; mat.ks = vector_init(.1, .1, .1); mat.kd = vector_init(1, 1, 0); scene[object_count++] = init_cylinder(vector_init(.0, .0, .0), vector_init(1, 0, 0), 1, .05, mat); scene[object_count++] = init_cylinder(vector_init(.0, .0, .0), vector_init(0, 1, 0), 1, .05, mat); scene[object_count++] = init_cylinder(vector_init(.0, .0, .0), vector_init(0, 0, 1), 1, .05, mat); }
void init_scene(t_rt *rt, char *scene) { if (rt) { rt->objs = NULL; rt->lights = NULL; if (!(rt->camera)) init_camera(&(rt->camera), *(rt->screen), rt->space); load_scene(rt, scene); if (!(rt->lights)) init_lights(&(rt->lights)); if (!(rt->objs)) init_objs(&(rt->objs)); if (scene) free(scene); } }
void MyGLWidget::initializeGL () { // Cal inicialitzar l'ús de les funcions d'OpenGL initializeOpenGLFunctions(); glClearColor(0.5, 0.7, 1.0, 1.0); // defineix color de fons (d'esborrat) glEnable(GL_DEPTH_TEST); carregaShaders(); createBuffers(); //FUNCIONS PROPIES______________ distanciaMaximaEscena(); init_camera(); refreshColFocus(); refreshPosFocus(); projectTransform (); viewTransform (); }
int Camera::doSetup(const int & format) { #ifdef _WIN32 do_software_unlock(); ds_camera_ = new CCameraDS(); int camera_count = CCameraDS::CameraCount(); char camera_name[255] = { 0 }; char camera_vid[10] = { 0 }; char camera_pid[10] = { 0 }; int i = 0, touchCameraId = -1; while (i < camera_count) { CCameraDS::CameraInfo(i, camera_vid, camera_pid); // VID PID is more reasonable if (0 == strncmp(camera_vid, TP_CAMERA_VID, 4) && 0 == strncmp(camera_pid, TP_CAMERA_PID, 4)) { touchCameraId = i; break; } i++; } if (-1 == touchCameraId) { return false; } const int fmt = 1; myBuffer = (unsigned char *)malloc(1280 * 480 * 3); image_out.data = myBuffer; bool retV = ds_camera_->OpenCamera(touchCameraId, format, 1280, 480, 60, frameCallback); printf("camera opened = %d\n", retV); Camera::opened = true; return retV; #elif __APPLE__ init_camera(); return 1; #endif }
/* * Ubiquitous main function, argv and all * */ int main(int argc, char* argv[]) { int bez[] = { GLUT_KEY_F1, GLUT_KEY_F2, GLUT_KEY_F3, GLUT_KEY_F4, GLUT_KEY_F5, GLUT_KEY_F6, GLUT_KEY_F7, GLUT_KEY_F8, GLUT_KEY_F9, 0, }; glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE); glutCreateWindow("University of Missouri Campus"); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMouseFunc(mouse_click); glutMotionFunc(mouse_drag); // real-time muliple key-presses initKeyboard(50); keyboardCallbackv("asdfhjklionm", move_camera); keyboardCallback(27, closeWin); keyboardSpecialCallback(GLUT_KEY_F12, fillMode); keyboardSpecialCallback(GLUT_KEY_F11, free_camera); keyboardSpecialCallback(GLUT_KEY_F10, circle_camera); keyboardSpecialCallbackv(bez, bezier_camera); init_lights(); init_campus(); init_camera(); glutFullScreen(); glutMainLoop(); return 0; }
void MyGLWidget::paintGL () { // Esborrem el frame-buffer (PER DEFECTE) glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Inicialitzem variables de la camera init_camera(); //************OBJECTE 1 HOMER****************// // 1 .Project+View // 2. Transformacio del model a pintar modelTransformRot(); // 3. Pintem objectes // Activem el VAO per a pintar homer glBindVertexArray (VAO_Homer); //View glDrawArrays (GL_TRIANGLES, 0, m.faces().size()*3); //************OBJECTE 2 TERRA***************// //Tranformacio del model (nomes es torna a aplicar el model // transform que es l'unic que volem // diferent) modelTransform (); glBindVertexArray (VAO_Terra); // pintem glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glBindVertexArray (0); }
void setup_scene_3() { theCamera = init_camera(vector_init(2, 1, 3), vector_init(0, 0.3, 0), vector_init(0, 1, 0), 60, (float) WIDTH / (float) HEIGHT); lights[0].position = vector_init(-2, 1.7, 3); lights[0].col = vector_init(1, 1, 1); lights[1].position = vector_init(3, 2, 3); lights[1].col = vector_init(0.4, 0.4, 0.4); lights[2].position = vector_init(4, 3, -10); lights[2].col = vector_init(0.5, 0.5, 0.5); num_lights = 3; object_count = 0; material mat; mat.shininess = 20; mat.kd = vector_init(1, 0, 0); mat.ks = vector_init(.5, .5, .5); mat.reflect_coef = 0.8; for (int i = 0; i < SCENE_SIZE; i++) { mat.kd = vector_init(((float) (rand() % 255)) / 255.f, ((float) (rand() % 255)) / 255.f, ((float) (rand() % 255)) / 255.f); scene[object_count++] = init_sphere(((float) (rand() % 8)) / 4.f, ((float) (rand() % 8)) / 4.f, ((float) (rand() % 8)) / 4.f, .1, mat); } }
int main() { if(chdir(PKGDATADIR) != 0) { printf("data directory %s not found.", PKGDATADIR); } init(); init_camera(); init_board(&board); init_striker(&striker); init_chips(); init_orientation(&striker); init_instructions(); init_speed_text(); init_main_menu(); init_scores(); init_game_over_state(); move_to_main_menu(); while(!quit) { frame_start(); while(!quit && accumulator >= elapsed_time) { handle_events(); update(); render(); accumulator -= elapsed_time; } } close(); }
int main() { void *buffer1,*buffer2,*buffer3,*buffer4; unsigned short *image; unsigned char *grayscale; unsigned char current_mode; unsigned char mode; init_LCD(); init_camera(); vga_set_swap(VGA_QuarterScreen|VGA_Grayscale); printf("Hello from Nios II!\n"); cam_get_profiling(); buffer1 = (void *) malloc(cam_get_xsize()*cam_get_ysize()); buffer2 = (void *) malloc(cam_get_xsize()*cam_get_ysize()); buffer3 = (void *) malloc(cam_get_xsize()*cam_get_ysize()); buffer4 = (void *) malloc(cam_get_xsize()*cam_get_ysize()); cam_set_image_pointer(0,buffer1); cam_set_image_pointer(1,buffer2); cam_set_image_pointer(2,buffer3); cam_set_image_pointer(3,buffer4); enable_continues_mode(); init_sobel_arrays(cam_get_xsize()>>1,cam_get_ysize()); do { if (new_image_available() != 0) { if (current_image_valid()!=0) { current_mode = DIPSW_get_value(); mode = current_mode&(DIPSW_SW1_MASK|DIPSW_SW3_MASK|DIPSW_SW2_MASK); image = (unsigned short*)current_image_pointer(); switch (mode) { case 0 : transfer_LCD_with_dma(&image[16520], cam_get_xsize()>>1, cam_get_ysize(),0); if ((current_mode&DIPSW_SW8_MASK)!=0) { vga_set_swap(VGA_QuarterScreen); vga_set_pointer(image); } break; case 1 : conv_grayscale((void *)image, cam_get_xsize()>>1, cam_get_ysize()); grayscale = get_grayscale_picture(); transfer_LCD_with_dma(&grayscale[16520], cam_get_xsize()>>1, cam_get_ysize(),1); if ((current_mode&DIPSW_SW8_MASK)!=0) { vga_set_swap(VGA_QuarterScreen|VGA_Grayscale); vga_set_pointer(grayscale); } break; case 2 : conv_grayscale((void *)image, cam_get_xsize()>>1, cam_get_ysize()); grayscale = get_grayscale_picture(); sobel_x_with_rgb(grayscale); image = GetSobel_rgb(); transfer_LCD_with_dma(&image[16520], cam_get_xsize()>>1, cam_get_ysize(),0); if ((current_mode&DIPSW_SW8_MASK)!=0) { vga_set_swap(VGA_QuarterScreen); vga_set_pointer(image); } break; case 3 : conv_grayscale((void *)image, cam_get_xsize()>>1, cam_get_ysize()); grayscale = get_grayscale_picture(); sobel_x(grayscale); sobel_y_with_rgb(grayscale); image = GetSobel_rgb(); transfer_LCD_with_dma(&image[16520], cam_get_xsize()>>1, cam_get_ysize(),0); if ((current_mode&DIPSW_SW8_MASK)!=0) { vga_set_swap(VGA_QuarterScreen); vga_set_pointer(image); } break; default: conv_grayscale((void *)image, cam_get_xsize()>>1, cam_get_ysize()); grayscale = get_grayscale_picture(); sobel_x(grayscale); sobel_y(grayscale); sobel_threshold(128); grayscale=GetSobelResult(); transfer_LCD_with_dma(&grayscale[16520], cam_get_xsize()>>1, cam_get_ysize(),1); if ((current_mode&DIPSW_SW8_MASK)!=0) { vga_set_swap(VGA_QuarterScreen|VGA_Grayscale); vga_set_pointer(grayscale); } break; } } } } while (1); return 0; }