-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to set font size and color in setOSD and createOSD methods. #326
Changes from 2 commits
781b0c6
4ecc50f
66988aa
429e14e
a52d665
6236882
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1245,11 +1245,17 @@ module.exports = function(Cam) { | |
|
||
/** | ||
* CreateOSD | ||
* ONVIF can handle custom positons, date/time, text, font sizes, transparency, images etc. We only support Plain Text | ||
* ONVIF can handle custom positons, date/time, text, font sizes, transparency, images etc. | ||
* Support - Plain Text, DateAndTime, Font size and Font color. | ||
* @param {Object} [options] | ||
* @param {string} [options.videoSourceConfigurationToken] Token of the Video Source Configuration, which has associated OSDs. Defaults to Active Source | ||
* @param {string} [options.plaintext] Text to overlay | ||
* @param {string} [options.position] UpperLeft, UpperRight, LowerLeft or LowerRight. Default LowerLeft (custom mode currently not implemented) | ||
* @param {object|string} [options.position] String options: UpperLeft, UpperRight, LowerLeft or LowerRight. Default LowerLeft. Or an object with x and y position | ||
* @param {number} [options.position.x] x position of OSD, range: -1 to 1, counting from left to right | ||
* @param {number} [options.position.y] y position of OSD, range: -1 to 1, counting from up to down | ||
* @param {string} [options.plaintext] Plain text to overlay | ||
* @param {string} [options.dateFormat] Date to overlay. Must be used with timeFormat, otherwise plaintext will be used. | ||
* @param {string} [options.timeFormat] Time to overlay. Must be used with dateFormat, otherwise plaintext will be used. | ||
* @param {number} [options.fontSize] The text font size. | ||
* @param {object} [options.fontColor] The color of the text font (OSDColor), should be object with properties - X, Y, Z. | ||
* @param {Cam~GetOSDOptionsCallback} callback | ||
*/ | ||
Cam.prototype.createOSD = function(options, callback) { | ||
|
@@ -1259,21 +1265,31 @@ module.exports = function(Cam) { | |
this._request({ | ||
service: mediaType | ||
, body: this._envelopeHeader() + | ||
`<wsdl:CreateOSD xmlns:wsdl="${mediaNS}" xmlns:sch="http://www.onvif.org/ver10/schema"> | ||
`<wsdl:CreateOSD xmlns:wsdl="${mediaNS}" xmlns:sch="http://www.onvif.org/ver10/schema"> | ||
<wsdl:OSD token=""> | ||
<sch:VideoSourceConfigurationToken>${(options.videoSourceConfiguationToken || this.activeSource.videoSourceConfigurationToken)}</sch:VideoSourceConfigurationToken> | ||
<sch:Type>Text</sch:Type> | ||
<sch:Position> | ||
<sch:Type>${options.position || 'LowerLeft'}</sch:Type> | ||
</sch:Position> | ||
<sch:TextString IsPersistentText="false"> | ||
<sch:Type>Plain</sch:Type> | ||
<sch:PlainText>${options.plaintext}</sch:PlainText> | ||
</sch:TextString> | ||
<sch:VideoSourceConfigurationToken>${options.videoSourceConfiguationToken || this.activeSource.videoSourceConfigurationToken}</sch:VideoSourceConfigurationToken> | ||
<sch:Type>Text</sch:Type> | ||
<sch:Position> | ||
<sch:Type>${ typeof options.position === "object" ? "Custom" : options.position ? options.position : "LowerLeft"}</sch:Type> | ||
${typeof options.position === "object" ? '<sch:Pos x="' + options.position.x + '" y="' + options.position.y + '"/>' : ""} | ||
</sch:Position> | ||
<sch:TextString IsPersistentText="false"> | ||
${ options.dateFormat && options.timeFormat ? | ||
`<sch:Type>DateAndTime</sch:Type> | ||
<sch:DateFormat>${options.dateFormat}</sch:DateFormat> | ||
<sch:TimeFormat>${options.timeFormat}</sch:TimeFormat>` | ||
: `<sch:Type>Plain</sch:Type> | ||
<sch:PlainText>${options.plaintext}</sch:PlainText>`} | ||
|
||
${options.fontSize ? `<sch:FontSize>${options.fontSize}</sch:FontSize>` : ""} | ||
${options.fontColor ? ` | ||
<sch:FontColor> | ||
${'<sch:Color Z="' + options.fontColor.Z + '" Y="' + options.fontColor.Y + '" X="' + options.fontColor.X + '"/>'} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added new options parameter - colorspace. |
||
</sch:FontColor>` : ""} | ||
</sch:TextString> | ||
</wsdl:OSD> | ||
</wsdl:CreateOSD>` + | ||
|
||
this._envelopeFooter() | ||
this._envelopeFooter(), | ||
}, function(err, data, xml) { | ||
if (callback) { | ||
callback.call(this, err, err ? null : linerase(data), xml); | ||
|
@@ -1283,7 +1299,8 @@ module.exports = function(Cam) { | |
|
||
/** | ||
* SetOSD | ||
* ONVIF can handle custom positons, date/time, text, font sizes, transparency, images etc. Both Plain Text and DateAndTime are supported. | ||
* ONVIF can handle custom positons, date/time, text, font sizes, transparency, images etc. | ||
* Support - Plain Text, DateAndTime, Font size and Font color. | ||
* @param {Object} options | ||
* @param {Object} options.OSDToken | ||
* @param {string} [options.videoSourceConfigurationToken] Token of the Video Source Configuration, which has associated OSDs. Defaults to Active Source | ||
|
@@ -1293,6 +1310,8 @@ module.exports = function(Cam) { | |
* @param {string} [options.plaintext] Plain text to overlay | ||
* @param {string} [options.dateFormat] Date to overlay. Must be used with timeFormat, otherwise plaintext will be used. | ||
* @param {string} [options.timeFormat] Time to overlay. Must be used with dateFormat, otherwise plaintext will be used. | ||
* @param {number} [options.fontSize] The text font size. | ||
* @param {object} [options.fontColor] The color of the text font (OSDColor), should be object with properties - X, Y, Z. | ||
* @param {Cam~GetOSDOptionsCallback} callback | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here link to createOSD method:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the link to create osd method. |
||
*/ | ||
Cam.prototype.setOSD = function(options, callback) { | ||
|
@@ -1317,7 +1336,20 @@ module.exports = function(Cam) { | |
<sch:DateFormat>${options.dateFormat}</sch:DateFormat> | ||
<sch:TimeFormat>${options.timeFormat}</sch:TimeFormat>` | ||
: `<sch:Type>Plain</sch:Type> | ||
<sch:PlainText>${options.plaintext}</sch:PlainText>`} | ||
<sch:PlainText>${options.plaintext}</sch:PlainText>`} | ||
|
||
${ | ||
options.fontSize ? | ||
`<sch:FontSize>${options.fontSize}</sch:FontSize>` : '' | ||
} | ||
${ | ||
options.fontColor ? | ||
` | ||
<sch:FontColor> | ||
${'<sch:Color Z="' + options.fontColor.Z + '" Y="' + options.fontColor.Y + '" X="' + options.fontColor.X + '"/>'} | ||
</sch:FontColor> | ||
` : '' | ||
} | ||
</sch:TextString> | ||
</wsdl:OSD> | ||
</wsdl:SetOSD>` + | ||
|
@@ -1330,7 +1362,6 @@ module.exports = function(Cam) { | |
}.bind(this) | ||
); | ||
}; | ||
|
||
/** | ||
* Delete OSD | ||
* @param {string} token | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add your example here:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added example to create osd.