/* * ***************************************************************** * * * * * Copyright (c) Fast Corporation, 1997 * * * * * * All Rights Reserved. Unpublished rights reserved under * * * the copyright laws of the Japan. * * * * * * The software contained on this media is proprietary to * * * and embodies the confidential technology of Fast * * * Corporation. Possession, use, duplication or * * * dissemination of the software and media is authorized only * * * pursuant to a valid written license from Fast Corporation. * * * * * ***************************************************************** */ /* CSC902 高分解能エリアセンサボード2枚実装チャネル切り替えサンプル 902hr2ch.c */ /*[作成者]A.Sekimori */ /* 目的: 関数: 履歴: Ver 1.0 00/06/22 注記:m_menu.hをインクルードして下さい。 m_menu.c及びm_note.cをリンクして下さい。 ○キャプチャボードIPM-8500Dを搭載した902シリーズでお使いになる場合は 902_hr2.lib ipm85lib.lib  をリンクしてください。 ○キャプチャボードFHC331、FHC331LVを搭載した902シリーズでお使いになる場合は 902_fhc.lib  をリンクしてください。 */ /* Include compiler runtime library */ #include #include /* Include CSC90X library */ #include "f_stdio.h" /* 標準入出力 */ #include "f_stdlib.h" /* メモリ領域割当 */ #include "f_time.h" /* 時刻サービス */ #include "f_gui.h" /* GUI */ #include "f_graph.h" /* モニタ表示 */ #include "f_pinf.h" /* システムパラメータ */ #include "f_video.h" /* ビデオ入力制御 */ #include "f_image.h" /* フレームバッファ */ #include "f_system.h" /* システム制御 */ #include "f_lsens.h" /* ラインセンサ */ #include "f_hres.h" /* 高分解能エリアセンサ */ /* * Include CSC90X common local */ #include "m_menu.h" /* * プロトタイプ宣言 */ void main( void ); void main_menu_disp( void ); void disp_help( void ); void select_camera( int *, int * ); void input_command_pad( int ); void test_input_control( int ); void input_control( int ); extern int message_note( void ); /* * メニュー項目 */ #define LANG_N 2 #define MAIN_MENU_N 2 static const char *str_main_menu[MAIN_MENU_N][LANG_N] = { { " CH0 ", "チャネル0" }, { " CH1 " , "チャネル1" } }; #define INIT_CUR_POS_X 255 #define INIT_CUR_POS_Y 239 static char *camera_table[3] = { "FC1300 ", "KP-F100", "CS3910 " }; int xpos; int ypos; /* メイン */ void main( void ) { int sts; int s_xpos; int s_ypos; int error; int ch0_type; /* カメラの種類(ch0) */ int ch1_type; /* カメラの種類(ch1) */ /* カーソル初期化 */ Lib_init_cursor(); /* 初期メッセージ表示 */ if( NORMAL_RETURN != message_note() ) return; ch0_type = FC1300; ch1_type = FC1300; select_camera( &ch0_type, &ch1_type ); Lib_high_res_set_video_channel( 0 ); if ( NORMAL_RETURN == ( error = Lib_high_res_init( ch0_type ) ) ) { Lib_high_res_set_video_channel( 1 ); if ( NORMAL_RETURN == ( error = Lib_high_res_init( ch1_type ) ) ) { /* パラメタ初期化 */ xpos = INIT_CUR_POS_X; ypos = INIT_CUR_POS_Y; s_xpos = INIT_CUR_POS_X; s_ypos = INIT_CUR_POS_Y; /* ビデオ出力表示項目制御 */ Lib_display_control( GRAY_PLANE | LINE_PLANE | CHAR_PLANE ); /* ビデオ表示項目クリア */ Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); /* メインメニューの表示 */ main_menu_disp(); /* マウスカーソルの表示 */ Lib_draw_cursor( INIT_CUR_POS_X, INIT_CUR_POS_Y ); /* メニュー制御 */ for (;;) { sts = 0; /* マウス位置読みとり */ sts = Lib_see_current_position( &xpos, &ypos ); if ( s_xpos != xpos || s_ypos != ypos ) { /* マウス表示位置移動 */ Lib_move_cursor( xpos, ypos ); s_xpos = xpos; s_ypos = ypos; } /* 処理振り分け */ if( CURSOR_EXECUTE == sts ) { if ( xpos > MENU_1_XS && xpos < MENU_1_XE && ypos > MENU_1_YS && ypos < MENU_1_YE ) { /*「チャネル0」が選択された */ input_command_pad( 0 ); main_menu_disp(); } else if ( xpos > MENU_2_XS && xpos < MENU_2_XE && ypos > MENU_2_YS && ypos < MENU_2_YE ) { /*「チャネル1」が選択された */ input_command_pad( 1 ); main_menu_disp(); } else if ( xpos > MENU_H_XS && xpos < MENU_H_XE && ypos > MENU_H_YS && ypos < MENU_H_YE ) { Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); disp_help(); /* ヘルプ */ main_menu_disp(); } else if ( xpos > MENU_E_XS && xpos < MENU_E_XE && ypos > MENU_E_YS && ypos < MENU_E_YE ) { break; /* 終了 */ } } } Lib_high_res_set_video_channel( 1 ); Lib_high_res_finish(); } else if ( ARG_ERR == error ) Lib_display_message( 120, 200, "エラー CH1", "カメラ種別が不明です。" ); else if ( UNUSUAL_ERR == error ) Lib_display_message( 120, 200, "エラー CH1", "ボードまたは902の初期化に失敗しました。" ); else if ( NO_DEVICE == error ) Lib_display_message( 120, 200, "エラー CH1", "ボードが存在していません。" ); Lib_high_res_set_video_channel( 0 ); Lib_high_res_finish(); } else if ( ARG_ERR == error ) Lib_display_message( 120, 200, "エラー CH0", "カメラ種別が不明です。" ); else if ( UNUSUAL_ERR == error ) Lib_display_message( 120, 200, "エラー CH0", "ボードまたは902の初期化に失敗しました。" ); else if ( NO_DEVICE == error ) Lib_display_message( 120, 200, "エラー CH0", "ボードが存在していません。" ); } /* メインメニュー表示 */ void main_menu_disp( void ) { int iLanguage; /* 日本語/英語表示文字列切替情報取得 */ iLanguage = Lib_get_disp_language(); /* 整列キー表示 -> ( m_menu.c ) */ SUB_menu_disp4he( (char *)str_main_menu[0][iLanguage], (char *)str_main_menu[1][iLanguage], (char *)NULL, (char *)NULL ); } /* ヘルプ表示 */ void disp_help( void ) { Lib_chrdisp( 6, 8, "【機能\概要】 902HR2CH.EXE" ); Lib_chrdisp( 7, 10, "このサンプルソ\フトは902シリーズにFHC331(LV)を2枚" ); Lib_chrdisp( 7, 11, "実装し2台の高分解能\エリアセンサを切り替えて濃淡" ); Lib_chrdisp( 7, 12, "画像を入力するサンプルです。" ); Lib_chrdisp( 7, 14, "竹中システム機器(株)製 FC1300" ); Lib_chrdisp( 7, 15, "竹中システム機器(株)製 FC1320V" ); Lib_chrdisp( 7, 16, "日立電子(株)製 KP−F100" ); Lib_chrdisp( 7, 17, "東京電子工業(株)製 CS3910" ); Lib_chrdisp( 7, 18, "に対応しています。" ); Lib_chrdisp( 7, 20, "【チャネル0】チャネル0に接続されたカメラからの画像入力。" ); Lib_chrdisp( 7, 22, "【チャネル1】チャネル1に接続されたカメラからの画像入力。" ); } /***** カメラの選択 *****/ void select_camera( int *ch0_type, int *ch1_type ) { PVAL value[4]; int no; int pad_level; int select_c0,select_c1; int idc; idc = Lib_shelter_plane( 0, 0, (Lib_get_dx_size() - 1), (Lib_get_dy_size() - 1), CHAR_PLANE ); pad_level = Lib_view_open(); /* パッドのオープン */ if ( FC1300 == *ch0_type ) select_c0 = 0; else if ( KP_F100 == *ch0_type ) select_c0 = 1; else if ( CS3910 == *ch0_type ) select_c0 = 2; if ( FC1300 == *ch1_type ) select_c1 = 0; else if ( KP_F100 == *ch1_type ) select_c1 = 1; else if ( CS3910 == *ch1_type ) select_c1 = 2; Lib_view_set_title( pad_level, "カメラ" ); /* パッドタイトルの登録 */ /* 各属性メニューの登録 */ Lib_view_set_comment( pad_level, 5, 5, "チャネル0", 0 ); Lib_view_set_select ( pad_level, 10, 35, "カメラ" , select_c0, 3, camera_table, 1 ); Lib_view_set_comment( pad_level, 5, 65, "チャネル1", 2 ); Lib_view_set_select ( pad_level, 10, 95, "カメラ" , select_c1, 3, camera_table, 3 ); /* パッドの表示位置の登録 */ Lib_view_set_size( pad_level, 20, 50, 5, 5 ); Lib_draw_menu( pad_level ); /* メニューパッドの表示 */ if ( ERROR_RETURN != ( no = Lib_process_menu( pad_level, value ) ) ) /* メニュー値の取得 */ { switch( no ) { case 101: /*「実行」が選択された */ select_c0 = value[1].select_type; select_c1 = value[3].select_type; break; case 102: /*「取り消し」が選択された */ break; } } if ( 0 == select_c0 ) *ch0_type = FC1300; else if ( 1 == select_c0 ) *ch0_type = KP_F100; else if ( 2 == select_c0 ) *ch0_type = CS3910; if ( 0 == select_c1 ) *ch1_type = FC1300; else if ( 1 == select_c1 ) *ch1_type = KP_F100; else if ( 2 == select_c1 ) *ch1_type = CS3910; Lib_erase_menu( pad_level ); /* メニューパッドの消去 */ Lib_view_close( pad_level ); /* パッドのクローズ */ Lib_recover_plane( idc ); } /***** 画像入力用コマンドパッド *****/ void input_command_pad( int ch ) { int no; int pad_level; int status_flag; Lib_cls( ( LINE_PLANE | CHAR_PLANE ), BLACK_COLOR ); pad_level = Lib_view_open(); Lib_view_set_title( pad_level, "入力" ); Lib_view_set_null( pad_level, 5, 5, "調整入力" , 0 ); Lib_view_set_null( pad_level, 5, 35, "画像入力" , 1 ); Lib_view_set_size( pad_level, 50, 50, 5, 5 ); Lib_draw_command( pad_level ); for ( status_flag = ON; OFF != status_flag; ) { if ( ERROR_RETURN != ( no = Lib_process_command( pad_level ) ) ) { switch( no ) { case 0: /* 調整入力 */ test_input_control( ch ); break; case 1: /* 画像入力 */ input_control( ch ); break; case 102: status_flag = OFF; break; } } } Lib_erase_command( pad_level ); Lib_view_close( pad_level ); Lib_cls( ( LINE_PLANE | CHAR_PLANE ), BLACK_COLOR ); } /***** 調整入力制御 *****/ void test_input_control( int ch ) { int idc; idc = Lib_shelter_plane( 0, 0, (Lib_get_dx_size() - 1), (Lib_get_dy_size() - 1), CHAR_PLANE ); Lib_erase_cursor(); Lib_high_res_set_video_channel( ch ); for ( ; ; ) { if ( CURSOR_CANCEL == Lib_see_current_position_real( &xpos, &ypos ) ) break; /* 入力開始 */ if ( NORMAL_RETURN == Lib_high_res_xfreeze() ) { /* 入力完了待ち */ for ( ; ; ) { if ( FINISHED_TRANSMIT == Lib_high_res_get_video_status() ) { Lib_ex_video_transmit( CURRENT_MEMORY, GRAY_PLANE, REDUCE_MODE ); break; } } } else Lib_display_message( 100, 200, "ERROR", "Lib_high_res_xfreeze" ); } Lib_look_current_position( &xpos, &ypos ); Lib_draw_cursor( xpos, ypos ); Lib_cls( GRAY_PLANE, BLACK_COLOR ); Lib_recover_plane( idc ); } /***** 画像入力 *****/ void input_control( int ch ) { char ss[50]; int time; int idc; idc = Lib_shelter_plane( 0, 0, (Lib_get_dx_size() - 1), (Lib_get_dy_size() - 1), CHAR_PLANE ); Lib_strtclk_count(); /* Lib_extraction_display_memoryを使用するために、入力プレーンを */ /* 表示プレーンに合わせる */ Lib_input_video_control( GRAY_PLANE ); Lib_high_res_set_video_channel( ch ); /* 入力開始 */ if ( NORMAL_RETURN == Lib_high_res_freeze( GRAY_PLANE, NOT_TRANSMIT ) ) { time = ( Lib_readclk_count() * 8138 ) / 10000; Lib_ex_video_transmit( CURRENT_MEMORY, GRAY_PLANE, REDUCE_MODE ); Lib_sprintf( ss, "入力時間 %5d(msec)", time ); Lib_chrdisp( 1, 30, ss ); Lib_display_keyinput( 460, 0, "確認" ); Lib_extraction_display_memory( CURRENT_MEMORY ); } else Lib_display_message( 100, 200, "ERROR", "Lib_lsensor_video_input" ); Lib_cls( ( GRAY_PLANE | LINE_PLANE | CHAR_PLANE ), BLACK_COLOR ); Lib_recover_plane( idc ); }