Closed aoforb closed 9 months ago
It is possible but it isn't necessarily user friendly. Here's an example that shows how to get the privacy mask settings of a camera.
$cam = Get-VmsCamera -Id '44E1D43D-4A54-4B8A-8E3D-513EB7007AAC'
$privacyMaskSettings = $cam.PrivacyProtectionFolder.PrivacyProtections[0]
$privacyMaskSettings | fl *
The above will return the following:
Enabled : False
Id : 44E1D43D-4A54-4B8A-8E3D-513EB7007AAC
PrivacyMaskXml : <mask><methods><blur id="0" motionDetection="true" removable="true" level="6" /></methods><grid
size="8x8"><cells><cell x="2" y="2" methodId="0" /><cell x="3" y="2" methodId="0" /><cell x="4" y="2"
methodId="0" /><cell x="2" y="3" methodId="0" /><cell x="3" y="3" methodId="0" /><cell x="4" y="3"
methodId="0" /><cell x="2" y="4" methodId="0" /><cell x="3" y="4" methodId="0" /><cell x="4" y="4"
methodId="0" /><cell x="2" y="5" methodId="0" /><cell x="3" y="5" methodId="0" /><cell x="4" y="5"
methodId="0" /></cells></grid></mask>
Methods : {}
ServerId : Id: fd06ac74-0b15-430c-9156-8653ea596e94 Uri: http://jmt-xpco.80
Name :
DisplayName : Privacy masking
Path : PrivacyProtection[44e1d43d-4a54-4b8a-8e3d-513eb7007aac]
ParentPath : Camera[44e1d43d-4a54-4b8a-8e3d-513eb7007aac]/PrivacyProtectionFolder
ItemCategory : Item
Description :
ParentItemPath : Camera[44e1d43d-4a54-4b8a-8e3d-513eb7007aac]
You can see that there is an Enabled property and a PrivacyMaskXml property. I can see the privacy masking is disabled but I do have a grid setup from a time when I had privacy masking enabled. I could do the following to Enable the privacy mask:
$privacyMaskSettings.Enabled = $true
$privacyMaskSettings.Save()
If you want to change the actual mask, then you need to create a new Xml blob and save it to $privacyMaskSettings.PrivacyMaskXml and then run $privacyMaskSettings.Save() again, like this:
$privacyMaskSettings.PrivacyMaskXml = '<mask><methods><solid id="0" motionDetection="false" removable="true" /></methods><grid size="8x8"><cells><cell x="6" y="0" methodId="0" /></cells></grid></mask>"'
$privacyMaskSettings.Save()
I'd recommend setting up privacy mask on a camera in the Management Client and then get the camera object in PSTools and do what I did above to see what it looks like. You can play around with adjusting the settings in the Management Client and then see how it changes the XML in order to get a feel for what you need to do.
One thing to note is that if you change the XML, the changes won't be visible in the Management Client. Instead, you will get this:
The Management Client will still show the proper status as far as enabled or disabled, even if that is done via PSTools.
One more thing to add on regarding the info about the Management Client showing a message saying the settings cannot be changed. I did some more digging and testing and this only happens if you set values that cannot be set in the Management Client. For example, in the Management Client, if you set the mask as "Liftable" then motion detection still happens behind the mask. If you set the mask as "Permanent", then motion detection doesn't happen behind the mask.
In the XML that you set for the privacy mask in PSTools, there are values for Removable and MotionDetection. If you set those to something that can't be set in the Management Client, then you get the message.
Essentially, if you set Removable to False and MotionDetection to True, then you will get that message. The same is true if you set Removable to True and MotionDetection to False.
This is a massive help, thank you for taking the time to respond.
Closing..
Hello,
Is it possible to configure Privacy Masking via the power shell API? If so could someone point me to the documentation and commands for this.
Thank you