cameraUVC.cc
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00089 #include "cameraUVC.h"
00090
00091 Driver* CameraUvc_Init(ConfigFile* cf, int section)
00092 {
00093 return((Driver*)(new CameraUvc(cf, section)));
00094 }
00095
00096 void CameraUVC_Register(DriverTable* table)
00097 {
00098 table->AddDriver("camerauvc", CameraUvc_Init);
00099 }
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 CameraUvc::CameraUvc(ConfigFile* cf, int section)
00113 : Driver(cf, section, true, PLAYER_MSGQUEUE_DEFAULT_MAXLEN, PLAYER_CAMERA_CODE)
00114 {
00115 ui=new UvcInterface(cf->ReadString(section, "port", "/dev/video0"),
00116 cf->ReadTupleInt( section, "size", 0, 320),
00117 cf->ReadTupleInt( section, "size", 1, 240));
00118 }
00119
00120 CameraUvc::~CameraUvc()
00121 {
00122 delete ui;
00123 }
00124
00125
00127
00128
00130 int CameraUvc::Setup()
00131 {
00132 printf("CameraUvc: Driver initialising\n");
00133
00134 if(ui->Open()==-1)
00135 {
00136 PLAYER_ERROR("CameraUvc: Error setting up video capture!");
00137 SetError(-1);
00138 return -1;
00139 }
00140
00141 StartThread();
00142 printf("CameraUvc: Driver initialisation done\n");
00143
00144 return 0;
00145 }
00146
00148
00149
00151 int CameraUvc::Shutdown()
00152 {
00153 printf("CameraUvc: Driver shutting down\n");
00154
00155 StopThread();
00156 ui->Close();
00157
00158 printf("CameraUvc: Driver shutdown complete\n");
00159 return 0;
00160 }
00161
00163
00165 void CameraUvc::Main()
00166 {
00167 while (true)
00168 {
00169
00170 pthread_testcancel();
00171
00172
00173 ProcessMessages();
00174
00175 ui->Read();
00176
00177
00178 data.width=ui->GetWidth();
00179 data.height=ui->GetHeight();
00180 data.bpp=24;
00181 data.format=PLAYER_CAMERA_FORMAT_RGB888;
00182 data.fdiv=1;
00183 data.compression=PLAYER_CAMERA_COMPRESS_JPEG;
00184 data.image_count=ui->GetFrameSize();
00185 data.image = new unsigned char[data.image_count];
00186 ui->CopyFrame(data.image);
00187
00188
00189 Publish (device_addr,PLAYER_MSGTYPE_DATA,PLAYER_CAMERA_DATA_STATE,&data);
00190 delete [] data.image;
00191 }
00192 }
00193
00195
00196
00198 int CameraUvc::ProcessMessage (QueuePointer &resp_queue, player_msghdr *hdr, void *data)
00199 {
00200 return -1;
00201 }
Last updated 12 September 2005 21:38:45
|