npCams plugin

About this plugin

This plugin allow you to control up to two Webcams at same time from your NeoBook publications. You can play the Webcam video in a NeoBook rectangle, pause, resume, stop and get images captures from the video. Include a motion detector.

The plugin offer to you a list of the available Webcams and their supported resolutions. Then you can specify a Webcam and one of their supported resolution to begin to play the Webcam video into a NeoBook rectangle.

Thirparty

This plugin are imposible without the aid of this people:

Thanks a lot!

Plugin actions index

npCamsCreate

Create a new instance of an Cam object and attach it to a Neobook rectangle object. The result variable store "True" if everything is OK, or "False" if not. In this last case the [LastError] contain information about the error.

↑↑

npCamsDestroy

Destroy a previously created Cam object instance and deattach from their NeoBook rectangle. The result variable store "True" if everything is OK, or "False" if not. In this last case the [LastError] contain information about the error.

↑↑

npCamsDestroyAll

Destroy all previously created instances of Cam objects.

↑↑

npCamsVideoStart

Start the specified Cam object begin getting the associated Webcam video and show in the specified NeoBook rectangle. Before you call this action you need to know the appropiate Webcam device identifier. The action npCamsDevices allow you to get all the available devices identifiers, so you can get one of them and use it with the action. The result variable store "True" if everything is OK, or "False" if not. In this last case the [LastError] contain information about the error.

↑↑

npCamsVideoStop

Stop the specified Cam object in the specified NeoBook rectangle. The result variable store "True" if everything is OK, or "False" if not. In this last case the [LastError] contain information about the error.

↑↑

npCamsVideoPause

Pause a previously started Cam object in the specified NeoBook rectangle. The result variable store "True" if everything is OK, or "False" if not. In this last case the [LastError] contain information about the error.

↑↑

npCamsVideoResume

Resume a previously paused Cam object in the specified NeoBook rectangle. The result variable store "True" if everything is OK, or "False" if not. In this last case the [LastError] contain information about the error.

↑↑

npCamsDevices

Get the available Webcam devices identifiers, in order to be available to use with others plugin actions. This action provide you the list of available Webcams. Every item in this list is a device identifer that you need to specify in other plugin actions.

Take a look at this code, which use this action in order to find if some Webcam are available and list it in a ListBox object:

.Use the action to get the available devices
npCamsDevices "[CamsDevices]" "[CamsDevicesCount]"

.Find if at least one Webcam is available
If "[CamsDevicesCount]" ">" ""

  .Create our webcam object
  npCamsCreate "WebCamRect" "[Result]"
  
  .And add to a NeoBook ListBox the Webcam identifiers
  Loop "0" "[CamsDevicesCount]" "[I]"
    ListBoxAddItem "WebCamsList" "0" "[CamsDevices[I]]"
  EndLoop
  
  .Now select the first devices
  SetVar "[WebCamsList]" "[CamsDevices0]"
  
Else

  .No Webcam found in the system
  AlertBox "No cams found!" "No cams found!"
  Exit "" ""
EndIf

↑↑

npCamsGetCapture

Get a bitmap image capture from the specified Cam object. You need to specify the BITMAP image path in order to save the capture. The result variable store "True" if everything is OK, or "False" if not. In this last case the [LastError] contain information about the error.

↑↑

npCamsGetVideoSize

Get the video width and height of the specified Cam object. This action place into the specified variables the width and height of the current video resolution.

↑↑

npCamsGetVideoSizes

Get the supported video sizes list from the specified Cam object. Use this action in order to get the supported Webcam video resolution, in order to use the npCamsSetVideoSize action to change the video resolution.

Note that before you call this action you must to call npCamsVideoStart action, in order to retrieve the video resolutions supported by the started Webcam device. Take a look at the below code, which show how to use this action:

.In WebCamsList we have the name of a Webcam device
If "[WebCamsList]" "=" ""
  AlertBox "Warning" "Select a Webcam from the list first"
  
Else
  .Start the Webcam video
  npCamsVideoStart "WebCamRect" "[WebCamsList]" "[Result]"

  .Initialize the video resolutions list  
  ListBoxDeleteItem "SizesList" "All"
  
  .And get the supported video resolutions
  npCamsGetVideoSizes "WebCamRect" "[CamsVideoSizes]" "[CamsVideoSizesCount]"
  
  .To add into the video resolutions list
  Loop "0" "[CamsVideoSizesCount]" "[I]"
    ListBoxAddItem "SizesList" "0" "[CamsVideoSizes[I]]"
  EndLoop
EndIf 

↑↑

npCamsSetVideoSize

Set one of the supported video size for the specified Cam object. Before you call this action you need to use the npCamsGetVideoSizes action, which provide you all the available video resolutions supported by the started Webcam device. You need to specity here one of the video resolutions string returned by the refered action. The result variable store "True" if everything is OK, or "False" if not. In this last case the [LastError] contain information about the error.

↑↑

npCamsMotionDetector

Set motion detector options for the specified Cams object. The result variable store "True" if everything is OK, or "False" if not. In this last case the [LastError] contain information about the error. The options you can set are listed below:

Note you need to play with "Tolerance" and "MinDifference" in order to get the better possible results depending of the webcam video resolution. "Tolerance and "MinDifference" can be adjusted to exclude background noise and so on.

↑↑

npOnCamsClick

Set a subroutine to be executed when the user click on a Cams instance object. You receive on the rectangle variable the name of the rectangle that bar is attached on. The result variable store "True" if everything is OK, or "False" if not. In this last case the [LastError] contain information about the error.

↑↑

npOnCamsDblClick

Set a subroutine to be executed when the user double click on a Cams instance object. You receive on the rectangle variable the name of the rectangle that bar is attached on. The result variable store "True" if everything is OK, or "False" if not. In this last case the [LastError] contain information about the error.

↑↑

npOnCamsMouseDown

Set a publication subroutine to be executed when the Cams object mouse down event is fired. The rectangle variable store the rectangle in which the mouse down has made. The button variable can contain one the values: mbLeft, mbMiddle or mbRight. The X variable store the mouse X position, and the Y variable the Y mouse position. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npOnCamsMouseMove

Set a publication subroutine to be executed when the Cams object mouse move event is fired. The rectangle variable store the rectangle in which the mouse move has made. The X variable store the mouse X position, and the Y variable the Y mouse position. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npOnCamsMouseUp

Set a publication subroutine to be executed when the Cams object mouse up event is fired. The rectangle variable store the rectangle in which the mouse up has made. The button variable can contain one the values: mbLeft, mbMiddle or mbRight. The X variable store the mouse X position, and the Y variable the Y mouse position. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

Action errors subroutine

All the NeoPlugins deal with errors in the same way that NeoBook does: when the plugin found an action error the [LastError] variable store information about the error, so you can take care about this variable when execute an action.

But all the NeoPlugins also incorporate an advanced way to deal with possible action errors. You can define a subroutine named OnNeoPluginActionError in order to be executed when some action error are found and you can use this variables inside:

Note that this error handling subroutine are shared for all the NeoPlugins, so you no need to specify a subroutine for every plugin you use in your publication because the same subroutine are recognized and automagically used by every NeoPlugin. Below you can view a sample of this subroutine code:

:OnNeoPluginActionError
  AlertBox "NeoPlugin Error" "Error [LastError] in plugin: [PluginName]"
Return

Also note that the use of this NeoPlugins error handling subroutine is completelly optional. You can continue using the [LastError] variable as usual and even use the both methods at the same time.

↑↑