It is currently Tue Jan 26, 2021 1:51 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 62 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
 Post subject: Re: Another Webcam Demo Program
PostPosted: Tue Sep 12, 2017 12:25 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Oct 24, 2005 1:05 pm
Posts: 745
Code:
IAMVideoProcAmp::Set


https://msdn.microsoft.com/en-us/library/windows/desktop/dd407328(v=vs.85).aspx

Quote:
Constants

VideoProcAmp_Brightness
Specifies the brightness, also called the black level. For NTSC, the value is expressed in IRE units * 100. For non-NTSC sources, the units are arbitrary, with zero representing blanking and 10,000 representing pure white. Values range from –10,000 to 10,000.
VideoProcAmp_Contrast
Specifies the contrast, expressed as gain factor * 100. Values range from zero to 10,000.
VideoProcAmp_Hue
Specifies the hue, in degrees * 100. Values range from -180,000 to 180,000 (-180 to +180 degrees).
VideoProcAmp_Saturation
Specifies the saturation. Values range from 0 to 10,000.
VideoProcAmp_Sharpness
Specifies the sharpness. Values range from 0 to 100.
VideoProcAmp_Gamma
Specifies the gamma, as gamma * 100. Values range from 1 to 500.
VideoProcAmp_ColorEnable
Specifies the color enable setting. The possible values are 0 (off) and 1 (on).
VideoProcAmp_WhiteBalance
Specifies the white balance, as a color temperature in degrees Kelvin. The range of values depends on the device.
VideoProcAmp_BacklightCompensation
Specifies the backlight compensation setting. Possible values are 0 (off) and 1 (on).
VideoProcAmp_Gain
Specifies the gain adjustment. Zero is normal. Positive values are brighter and negative values are darker. The range of values depends on the device.


__________________________________________________
URL tags added
18.09.2017
RSBasic


Top
 Profile  
Reply with quote  
 Post subject: Re: Another Webcam Demo Program
PostPosted: Tue Sep 12, 2017 1:13 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1801
Location: Pas-de-Calais, France
Could you test this new escapi.pbi with camera properties set/get functions ?
Code:
;/* Extremely Simple Capture API */

Structure SimpleCapParams
   *mTargetBuf ; Must be at least mWidth * mHeight * SizeOf(int) of size!
   mWidth.l
   mHeight.l
EndStructure

;/* Return the number of capture devices found */
PrototypeC countCaptureDevicesProc()

; /* initCapture tries To open the video capture device.
;  * Returns 0 on failure, 1 on success.
;  * Note: Capture parameter values must Not change While capture device
;  *       is in use (i.e. between initCapture And deinitCapture).
;  *       Do *Not* free the target buffer, Or change its pointer!
;  */
PrototypeC initCaptureProc(deviceno, *aParams.SimpleCapParams)

;/* deinitCapture closes the video capture device. */
PrototypeC deinitCaptureProc(deviceno)

;/* doCapture requests video frame To be captured. */
PrototypeC doCaptureProc(deviceno)

;/* isCaptureDone returns 1 when the requested frame has been captured.*/
PrototypeC isCaptureDoneProc(deviceno)

;/* Get the user-friendly name of a capture device. */
PrototypeC getCaptureDeviceNameProc(deviceno, *namebuffer, bufferlength)

Enumeration CAPTURE_PROPERTIES ;Name corrected
   #CAPTURE_BRIGHTNESS = 0
   #CAPTURE_CONTRAST
   #CAPTURE_HUE
   #CAPTURE_SATURATION
   #CAPTURE_SHARPNESS
   #CAPTURE_GAMMA
   #CAPTURE_COLORENABLE
   #CAPTURE_WHITEBALANCE
   #CAPTURE_BACKLIGHTCOMPENSATION
   #CAPTURE_GAIN
   #CAPTURE_PAN
   #CAPTURE_TILT
   #CAPTURE_ROLL
   #CAPTURE_ZOOM
   #CAPTURE_EXPOSURE
   #CAPTURE_IRIS
   #CAPTURE_FOCUS
   #CAPTURE_PROP_MAX
 EndEnumeration
 
;/* Gets value (0..1) of a camera property (see CAPTURE_PROPERTIES, above) */
PrototypeC.f getCapturePropertyValueProc(deviceno, prop)
;/* Gets whether the property is set To automatic (see CAPTURE_PROPERTIES, above) */
PrototypeC getCapturePropertyAutoProc(deviceno, prop);
;/* Set camera property To a value (0..1) And whether it should be set To auto. */
PrototypeC setCapturePropertyProc(deviceno, prop, value.f, autoval);

;/* Returns the ESCAPI DLL version. 0x200 For 2.0 */
PrototypeC ESCAPIDLLVersionProc()

; marked as "internal" in the example
PrototypeC initCOMProc()

;/* initCaptureWithOptions allows additional options To be given. Otherwise it's identical with initCapture
PrototypeC initCaptureWithOptionsProc(deviceno, *aParams.SimpleCapParams, aOptions)


Global countCaptureDevices.countCaptureDevicesProc
Global initCapture.initCaptureProc
Global deinitCapture.deinitCaptureProc
Global doCapture.doCaptureProc
Global isCaptureDone.isCaptureDoneProc
Global initCOM.initCOMProc
Global getCaptureDeviceName.getCaptureDeviceNameProc
Global getCapturePropertyValue.getCapturePropertyValueProc
Global getCapturePropertyAuto.getCapturePropertyAutoProc
Global setCaptureProperty.setCapturePropertyProc 
Global ESCAPIDLLVersion.ESCAPIDLLVersionProc
Global initCaptureWithOptions.initCaptureWithOptionsProc

Macro MyGetFunction(var, dll, function)
  var = GetFunction(dll, function)
  If var = 0
    Debug "Unsupported function : " + function
    error = #True
  EndIf
EndMacro

Procedure setupESCAPI()
   
  ; load library
  capdll = OpenLibrary(#PB_Any, "escapi.dll")
  If capdll = 0
    ProcedureReturn 0
  EndIf
 
  Define init
 
   ;/* Fetch function entry points */
  Define error = #False
  MyGetFunction(countCaptureDevices    , capdll, "countCaptureDevices")
  MyGetFunction(initCapture            , capdll, "initCapture")
  MyGetFunction(deinitCapture          , capdll, "deinitCapture")
  MyGetFunction(doCapture              , capdll, "doCapture")
  MyGetFunction(isCaptureDone          , capdll, "isCaptureDone")
  MyGetFunction(initCOM                , capdll, "initCOM")
  MyGetFunction(getCaptureDeviceName   , capdll, "getCaptureDeviceName")
  MyGetFunction(ESCAPIDLLVersion       , capdll, "ESCAPIDLLVersion")
  ;MyGetFunction(initCaptureWithOptions , capdll, "initCaptureWithOptions")
  MyGetFunction(getCapturePropertyValue, capdll, "getCapturePropertyValue")
  MyGetFunction(getCapturePropertyAuto , capdll, "getCapturePropertyAuto")
  MyGetFunction(setCaptureProperty     , capdll, "setCaptureProperty")
 
  If error
    Debug "Error while getting some dll functions."
  EndIf
   
   ;/* Verify DLL version */
   If ESCAPIDLLVersion() < $200
     ProcedureReturn 0
   EndIf
 
   ;/* Initialize COM.. */
   initCOM();
 
  ; returns number of devices found
  ProcedureReturn countCaptureDevices()
EndProcedure


Last edited by djes on Wed Sep 13, 2017 8:22 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Another Webcam Demo Program
PostPosted: Tue Sep 12, 2017 7:53 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Oct 24, 2005 1:05 pm
Posts: 745
I added the following lines to the new escapi.pbi:

Code:
#VideoProcAmp_Flags_Auto   = 1
#VideoProcAmp_Flags_Manual   = 2

The new code compiles and runs but I am not seeing any change to the camera image.

The following two lines of code both return zero:

Code:
setCaptureProperty(#DEVICE,#CAPTURE_GAMMA,50,#VideoProcAmp_Flags_Manual)
Debug getCapturePropertyValue(#DEVICE,#CAPTURE_GAMMA)

I chose gamma because the default is 1 and the range is 1 to 500, so I should get a non-zero result regardless.


Top
 Profile  
Reply with quote  
 Post subject: Re: Another Webcam Demo Program
PostPosted: Tue Sep 12, 2017 9:36 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1801
Location: Pas-de-Calais, France
I'll look tomorrow but normally, the value is a float, from 0 to 1


Top
 Profile  
Reply with quote  
 Post subject: Re: Another Webcam Demo Program
PostPosted: Wed Sep 13, 2017 1:56 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Oct 24, 2005 1:05 pm
Posts: 745
Quote:
VideoProcAmp_Gamma
Specifies the gamma, as gamma * 100. Values range from 1 to 500.


Top
 Profile  
Reply with quote  
 Post subject: Re: Another Webcam Demo Program
PostPosted: Wed Sep 13, 2017 8:14 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1801
Location: Pas-de-Calais, France
chris319 wrote:
Quote:
VideoProcAmp_Gamma
Specifies the gamma, as gamma * 100. Values range from 1 to 500.

Normally, but escapi uses normalized ranges from 0..1 and converts to the needed range.
Same for auto, to be set as TRUE/FALSE, not 1/2.

I've slighly modified the PBI to return a float value from getCapturePropertyValueProc().


Top
 Profile  
Reply with quote  
 Post subject: Re: Another Webcam Demo Program
PostPosted: Wed Sep 13, 2017 11:00 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Oct 24, 2005 1:05 pm
Posts: 745
Quote:
escapi uses normalized ranges from 0..1 and converts to the needed range.
Same for auto, to be set as TRUE/FALSE, not 1/2.


Right, but we're dealing with DirectShow here.

https://msdn.microsoft.com/en-us/librar ... 08(v=vs.85).aspx


Top
 Profile  
Reply with quote  
 Post subject: Re: Another Webcam Demo Program
PostPosted: Wed Sep 13, 2017 11:21 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1801
Location: Pas-de-Calais, France
chris319 wrote:
Quote:
escapi uses normalized ranges from 0..1 and converts to the needed range.
Same for auto, to be set as TRUE/FALSE, not 1/2.


Right, but we're dealing with DirectShow here.

https://msdn.microsoft.com/en-us/librar ... 08(v=vs.85).aspx

:? You're using escapi.dll, right ? Escapi is using directshow, but converts your values (0..1) to needed directshow values. For example, if you're using setCaptureProperty(device, #CAPTURE_HUE, 1, #False); escapi asks for a hue of 180. See capture.cpp/lines 292, 296, 311, 315.


Top
 Profile  
Reply with quote  
 Post subject: Re: Another Webcam Demo Program
PostPosted: Mon Sep 18, 2017 11:52 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Oct 24, 2005 1:05 pm
Posts: 745
Any progress?


Top
 Profile  
Reply with quote  
 Post subject: Re: Another Webcam Demo Program
PostPosted: Mon Sep 18, 2017 12:50 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1801
Location: Pas-de-Calais, France
I'm sorry but, progress about what ?


Top
 Profile  
Reply with quote  
 Post subject: Re: Another Webcam Demo Program
PostPosted: Mon Sep 18, 2017 10:50 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Oct 24, 2005 1:05 pm
Posts: 745
djes wrote:
I'm sorry but, progress about what ?

PB control of webcam proc amp controls.


Top
 Profile  
Reply with quote  
 Post subject: Re: Another Webcam Demo Program
PostPosted: Tue Sep 19, 2017 6:56 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1801
Location: Pas-de-Calais, France
It works perfectly for me, just by using floating point values instead of integer.

I can change this behaviour in the dll if you want, but beware that some parameters could be difficult to adjust.


Top
 Profile  
Reply with quote  
 Post subject: Re: Another Webcam Demo Program
PostPosted: Tue Sep 19, 2017 9:07 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Oct 24, 2005 1:05 pm
Posts: 745
It works now -- I had to straighten out the values of the flags. Your help is very much appreciated.

Next will be to discover the ranges of these controls and to work on the pan, tilt, zoom etc.


Top
 Profile  
Reply with quote  
 Post subject: Re: Another Webcam Demo Program
PostPosted: Tue Sep 19, 2017 10:03 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1801
Location: Pas-de-Calais, France
Thank you ! The escapi calculus is based on previously quoted values from directshow, reduced on the 0..1 range. So you have to do the inverse operation to have the correct values.
For example with
Quote:
VideoProcAmp_Contrast
Specifies the contrast, expressed as gain factor * 100. Values range from zero to 10,000.
the correct value is calculated with a cross product like this :
Code:
contrastmax = 10000 : contrastmin = 0
mycontrast = 5000
Escapicontrast.f = mycontrast / (contrastmax - contrastmin) ; = should be 0.5


Top
 Profile  
Reply with quote  
 Post subject: Re: Another Webcam Demo Program
PostPosted: Wed Sep 20, 2017 6:08 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Oct 24, 2005 1:05 pm
Posts: 745
Not all webcams support all of the controls. For example, gamma and sharpness are not supported on the Logitech BRIO. Better to set them to unity (0.5) on the camera and apply one's own controls.

I have added the following:
Code:
#VideoProcAmp_Flags_Auto = #True
#VideoProcAmp_Flags_Manual = #False


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 62 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: Amitris_de and 26 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye