kniazio wrote: ↑Tuesday 29 July 2025 6:16
Dodaj więcej informacji.
Dlaczego tutaj kniazio po polsku? Pewno dla innych będzie lepiej po angielsku.
Okay, I'll try to write it step by step.
A. Preparing for the Experiment
1. Use any Linux distribution (e.g., Debian, Fedora…),
2. Ensure UTC time matches on the camera and the system used for testing (if you synchronize time manually, ensure the correct time zone; it's best to use NTP on both sides; if you block the camera, unblock NTP ports or run your own NTP server within your network) – this is important for ONVIF.
3. If you have SSL enabled on the camera, the camera may redirect HTTP requests. In this case, it's better to use HTTPS or disable redirects.
4. Remember that many cameras have a separate ONVIF user pool. Verify this, and if necessary, create an ONVIF user.
B. Installation and Initial Configuration
1. Create a test directory (modify the username to the appropriate one):
2. Unpack the archive and place the onvif.pm file in /home/witek/test
3. Place test-onvif.pl anywhere you like.
4. Edit the test-onvif.pl file and change line:
Code: Select all
use lib "/path/todirectory/with/onvifmodule";
to
5. Set the $urlcam variable in test-onvif.pl (according to your camera's parameters).
6. Leave the GetDeviceInformation method uncommented (any ONVIF camera will handle this).
7. Leave the initial line (don't worry about MaxValueVideoParams):
Code: Select all
$onvif=onvif→new({ControlAddress=>$urlcam,MaxValueVideoParams=>100,SSLNoVerifycert=>1})
8. Run ./test-onvif.pl, you should receive a <tds:GetDeviceInformationResponse> with your camera's parameters.
9. During the first runs, Perl will inform you about missing modules (the messages are very clear). Install these modules one by one – they are included in the distribution; you can use Google to find the name of the missing library, e.g. in Google "debian perl LWP::UserAgent". You can also search like this (the double colon is a directory marker – so here the module will be in the UserAgent.pm file, in the LWP subdirectory):
Once you install everything, step 8 should work.
C. Final Configuration
1. Comment all methods in the test-onvif.pl file (below the # Below the methods… line)
2. Uncomment the $onvif→getProfiles(); method.
3. In the returned XML, find (in XPath syntax):
Code: Select all
//trt:GetProfilesResponse/trt:Profiles/tt:Name
– read the value (this profile is very important for executing many methods, it can be, for example, Profile000)
4. Additionally, find:
Code: Select all
//trt:GetProfilesResponse/trt:Profiles/tt:VideoSourceConfiguration/
– read the value,
5. Modify the object creation line in test-onvif.pl to:
Code: Select all
my $onvif=onvif→new({ControlAddress=>$urlcam, MaxValueVideoParams=>100,SSLNoVerifycert=>1, ControlDevice =>'Profile000',VideoSourceToken=>'VideoSource000',debug=>'0'});
where:
MaxValueVideoParams – is the maximum value of image parameters, e.g., Contrast
ControlDevice – read in step C.3
VideoSourceToken – read in step C.4
D. Other comments and suggestion
When executing XPath commands, XPath prefix compatibility is important – cameras have different prefixes, so in the PrintXML procedure, the registerNs method from XML::LibXML::XpathContext is called (I have two cameras at home, one with the s prefix, and the other with SOAP-ENV). If the module returns no prefix, simply add an additional line in the PrintXML.
For me, the most important was the presetGoto(idx) method, which allows the camera to be set to a preset position, but I think it's worth adding methods from the /onvif/event_service endpoint.
Perhaps we can add this here together?
For example, you can add here the code of an additional procedure, the content of the procedure can be relatively easily determined using wsdl files - they are readable, you need to remember that at least Three correct elements must be provided:
a) request name,
b) endpoint
c) xmlns - this is necessary for the camera to parse the request.
Good luck.