⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 videoio.cxx

📁 pwlib源码库
💻 CXX
📖 第 1 页 / 共 3 页
字号:
  return frameBrightness;}BOOL PVideoDevice::SetBrightness(unsigned newBrightness){  frameBrightness = newBrightness;  return TRUE;}int PVideoDevice::GetWhiteness(){  return frameWhiteness;}BOOL PVideoDevice::SetWhiteness(unsigned newWhiteness){  frameWhiteness = newWhiteness;  return TRUE;}int PVideoDevice::GetColour(){  return frameColour;}BOOL PVideoDevice::SetColour(unsigned newColour){  frameColour=newColour;  return TRUE;}int PVideoDevice::GetContrast(){  return frameContrast;}BOOL PVideoDevice::SetContrast(unsigned newContrast){  frameContrast=newContrast;  return TRUE;}int PVideoDevice::GetHue(){  return frameHue;}BOOL PVideoDevice::SetHue(unsigned newHue){  frameHue=newHue;  return TRUE;}    BOOL PVideoDevice::GetParameters (int *whiteness,                                  int *brightness,                                   int *colour,                                  int *contrast,                                  int *hue){  if (!IsOpen())    return FALSE;  *brightness = frameBrightness;  *colour     = frameColour;  *contrast   = frameContrast;  *hue        = frameHue;  *whiteness  = frameWhiteness;  return TRUE;}BOOL PVideoDevice::SetVideoChannelFormat (int newNumber, VideoFormat newFormat) {  BOOL err1, err2;  err1 = SetChannel (newNumber);  err2 = SetVideoFormat (newFormat);    return (err1 && err2);}PStringList PVideoDevice::GetDeviceNames() const{  return PStringList();}///////////////////////////////////////////////////////////////////////////////// PVideoOutputDevicePVideoOutputDevice::PVideoOutputDevice(){}BOOL PVideoOutputDevice::CanCaptureVideo() const{  return FALSE;}///////////////////////////////////////////////////////////////////////////////// PVideoOutputDeviceRGBPVideoOutputDeviceRGB::PVideoOutputDeviceRGB(){  PTRACE(6, "RGB\t Constructor of PVideoOutputDeviceRGB");  colourFormat = "RGB24";  bytesPerPixel = 3;  swappedRedAndBlue = false;  SetFrameSize(frameWidth, frameHeight);}BOOL PVideoOutputDeviceRGB::SetColourFormat(const PString & colourFormat){  PWaitAndSignal m(mutex);  PINDEX newBytesPerPixel;  bool newSwappedRedAndBlue;  if (colourFormat *= "RGB32") {    newBytesPerPixel = 4;    newSwappedRedAndBlue = false;  }  else if (colourFormat *= "RGB24") {    newBytesPerPixel = 3;    newSwappedRedAndBlue = false;  }  else if (colourFormat *= "BGR32") {    newBytesPerPixel = 4;    newSwappedRedAndBlue = true;  }  else if (colourFormat *= "BGR24") {    newBytesPerPixel = 3;    newSwappedRedAndBlue = true;  }  else    return FALSE;  if (!PVideoOutputDevice::SetColourFormat(colourFormat))    return FALSE;  bytesPerPixel = newBytesPerPixel;  scanLineWidth = ((frameWidth*bytesPerPixel+3)/4)*4;  return frameStore.SetSize(frameHeight*scanLineWidth);}BOOL PVideoOutputDeviceRGB::SetFrameSize(unsigned width, unsigned height){  PWaitAndSignal m(mutex);  if (!PVideoOutputDevice::SetFrameSize(width, height))    return FALSE;  scanLineWidth = ((frameWidth*bytesPerPixel+3)/4)*4;  return frameStore.SetSize(frameHeight*scanLineWidth);}PINDEX PVideoOutputDeviceRGB::GetMaxFrameBytes(){  PWaitAndSignal m(mutex);  return GetMaxFrameBytesConverted(frameStore.GetSize());}BOOL PVideoOutputDeviceRGB::SetFrameData(unsigned x, unsigned y,                                         unsigned width, unsigned height,                                         const BYTE * data,                                         BOOL endFrame){  PWaitAndSignal m(mutex);  if (x+width > frameWidth || y+height > frameHeight)    return FALSE;  if (x == 0 && width == frameWidth && y == 0 && height == frameHeight) {    if (converter != NULL)      converter->Convert(data, frameStore.GetPointer());    else      memcpy(frameStore.GetPointer(), data, height*scanLineWidth);  }  else {    if (converter != NULL) {      PAssertAlways("Converted output of partial RGB frame not supported");      return FALSE;    }    if (x == 0 && width == frameWidth)      memcpy(frameStore.GetPointer() + y*scanLineWidth, data, height*scanLineWidth);    else {      for (unsigned dy = 0; dy < height; dy++)        memcpy(frameStore.GetPointer() + (y+dy)*scanLineWidth + x*bytesPerPixel,               data + dy*width*bytesPerPixel, width*bytesPerPixel);    }  }  if (endFrame)    return FrameComplete();  return TRUE;}///////////////////////////////////////////////////////////////////////////////// PVideoOutputDevicePPM#ifdef SHOULD_BE_MOVED_TO_PLUGINPVideoOutputDevicePPM::PVideoOutputDevicePPM(){  PTRACE(6, "PPM\t Constructor of PVideoOutputDevicePPM");  frameNumber = 0;}BOOL PVideoOutputDevicePPM::Open(const PString & name,                                 BOOL /*startImmediate*/){  Close();  PFilePath path = name;  if (!PDirectory::Exists(path.GetDirectory()))    return FALSE;  if (path != psprintf(path, 12345))    deviceName = path;  else    deviceName = path.GetDirectory() + path.GetTitle() + "%u" + path.GetType();  return TRUE;}BOOL PVideoOutputDevicePPM::IsOpen(){  return !deviceName;}BOOL PVideoOutputDevicePPM::Close(){  deviceName.MakeEmpty();  return TRUE;}PStringList PVideoOutputDevicePPM::GetDeviceNames() const{  PStringList list;  list += PDirectory();  return list;}BOOL PVideoOutputDevicePPM::EndFrame(){  PFile file;  if (!file.Open(psprintf(deviceName, frameNumber++), PFile::WriteOnly)) {    PTRACE(1, "PPMVid\tFailed to open PPM output file \""           << file.GetName() << "\": " << file.GetErrorText());    return FALSE;  }  file << "P6 " << frameWidth  << " " << frameHeight << " " << 255 << "\n";  if (!file.Write(frameStore, frameStore.GetSize())) {    PTRACE(1, "PPMVid\tFailed to write frame data to PPM output file " << file.GetName());    return FALSE;  }  PTRACE(6, "PPMVid\tFinished writing PPM file " << file.GetName());  return file.Close();}#endif // SHOULD_BE_MOVED_TO_PLUGIN///////////////////////////////////////////////////////////////////////////////// PVideoInputDeviceBOOL PVideoInputDevice::CanCaptureVideo() const{  return TRUE;}static const char videoInputPluginBaseClass[] = "PVideoInputDevice";PStringList PVideoInputDevice::GetDriverNames(PPluginManager * pluginMgr){  if (pluginMgr == NULL)    pluginMgr = &PPluginManager::GetPluginManager();  return pluginMgr->GetPluginsProviding(videoInputPluginBaseClass);}PStringList PVideoInputDevice::GetDriversDeviceNames(const PString & driverName, PPluginManager * pluginMgr){  if (pluginMgr == NULL)    pluginMgr = &PPluginManager::GetPluginManager();  return pluginMgr->GetPluginsDeviceNames(driverName, videoInputPluginBaseClass);}PVideoInputDevice * PVideoInputDevice::CreateDevice(const PString &driverName, PPluginManager * pluginMgr){  if (pluginMgr == NULL)    pluginMgr = &PPluginManager::GetPluginManager();  return (PVideoInputDevice *)pluginMgr->CreatePluginsDevice(driverName, videoInputPluginBaseClass);}PVideoInputDevice * PVideoInputDevice::CreateDeviceByName(const PString & deviceName, PPluginManager * pluginMgr){  if (pluginMgr == NULL)    pluginMgr = &PPluginManager::GetPluginManager();  return (PVideoInputDevice *)pluginMgr->CreatePluginsDeviceByName(deviceName, videoInputPluginBaseClass);}PVideoInputDevice * PVideoInputDevice::CreateOpenedDevice(const PString & driverName,                                                          const PString & deviceName,                                                          BOOL startImmediate,                                                          PPluginManager * pluginMgr){  PVideoInputDevice * device;  if (driverName.IsEmpty() || driverName == "*")    device = CreateDeviceByName(deviceName, pluginMgr);  else    device = CreateDevice(driverName, pluginMgr);  if (device != NULL && device->Open(deviceName, startImmediate))    return device;  delete device;  return NULL;}BOOL PVideoInputDevice::GetFrame(PBYTEArray & frame){  PINDEX returned;  if (!GetFrameData(frame.GetPointer(GetMaxFrameBytes()), &returned))    return FALSE;  frame.SetSize(returned);  return TRUE;}////////////////////////////////////////////////////////////////////////////////////////////static const char videoOutputPluginBaseClass[] = "PVideoOutputDevice";PStringList PVideoOutputDevice::GetDriverNames(PPluginManager * pluginMgr){  if (pluginMgr == NULL)    pluginMgr = &PPluginManager::GetPluginManager();  return pluginMgr->GetPluginsProviding(videoOutputPluginBaseClass);}PStringList PVideoOutputDevice::GetDriversDeviceNames(const PString & driverName, PPluginManager * pluginMgr){  if (pluginMgr == NULL)    pluginMgr = &PPluginManager::GetPluginManager();  return pluginMgr->GetPluginsDeviceNames(driverName, videoOutputPluginBaseClass);}PVideoOutputDevice * PVideoOutputDevice::CreateDevice(const PString & driverName, PPluginManager * pluginMgr){  if (pluginMgr == NULL)    pluginMgr = &PPluginManager::GetPluginManager();  return (PVideoOutputDevice *)pluginMgr->CreatePluginsDevice(driverName, videoOutputPluginBaseClass);}PVideoOutputDevice * PVideoOutputDevice::CreateDeviceByName(const PString & deviceName, PPluginManager * pluginMgr){  if (pluginMgr == NULL)    pluginMgr = &PPluginManager::GetPluginManager();  return (PVideoOutputDevice *)pluginMgr->CreatePluginsDeviceByName(deviceName, videoOutputPluginBaseClass);}PVideoOutputDevice * PVideoOutputDevice::CreateOpenedDevice(const PString &driverName,                                                            const PString &deviceName,                                                            BOOL startImmediate,                                                            PPluginManager * pluginMgr){  PVideoOutputDevice * device;  if (driverName.IsEmpty() || driverName == "*")    device = CreateDeviceByName(deviceName, pluginMgr);  else    device = CreateDevice(driverName, pluginMgr);  if (device != NULL && device->Open(deviceName, startImmediate))    return device;  delete device;  return NULL;}// End Of File ///////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -