-
Notifications
You must be signed in to change notification settings - Fork 240
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
Conversation
lib/media.js
Outdated
${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 comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add Colorspace="http://www.onvif.org/ver10/colorspace/RGB"
here? Or add optional param to choose between YCbCr and RGB?
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 new options parameter - colorspace.
Supporting YCbCr and RGB.
lib/media.js
Outdated
* @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 comment
The reason will be displayed to describe this comment to others. Learn more.
You can add your example here:
* @example
* await cam.createOSD({
* videoSourceConfigurationToken: "VideoSourceConfigToken-01-0",
* OSDToken: "OSDDateTimeToken-0",
* position: "LowerLeft",
* timeFormat: "HH:mm:ss",
* dateFormat: "YYYY-MM-DD",
* fontSize: 1,
* fontColor: {
* X: 82,
* Y: 90,
* Z: 240,
* }
* });
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.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
And here link to createOSD method:
* @see {Cam~createOSD}
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 the link to create osd method.
adding extra validation to the font color parameters. adding documentation and example to the function parameters.
I have added an optional parameter - 'colorspace', allowing support for both YCbCr and RGB. The default setting is RGB.
and fix the request for the support (with extra validation to the parameters X,Y,Z) -
I added extra documentation to the font color parameter.
I added example to the parameters for createOSD method.
I added the link to create osd method in the setOSD method.
|
@RotemDoar Great, thanks! Nice and detailed comments 😸 |
I implemented the capability to adjust font size and color within both the 'setOSD' and 'createOSD' methods.
While working, I recognized the necessity to customize font attributes like size and color in the screen display.
Upon reviewing the Onvif MediaBinding spec (both media and media2 versions) -
https://www.onvif.org/ver10/media/wsdl/media.wsdl
https://www.onvif.org/ver20/media/wsdl/media.wsdl
I found that in the setOSD and createOSD function it is possible to set the font color and size.
To adding the ability, I introduced new parameters to the method options for setting font size and color in the 'setOSD' and 'createOSD' functions defined in media.js file:
And in the request body as part of the TextString I added :
Example of request options while I run the changes for one of my cameras -
As a result the font color configuration (X,Y,Z) changed the OSD color to red with minimum size of the font .
Moreover, I enhanced the 'create OSD' method to include the functionality of setting custom position, date, and time, aligning with the capabilities offered in the 'set OSD' method.