Skip to content
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

Failed to connect to camera #12

Closed
atirage opened this issue Feb 12, 2019 · 10 comments
Closed

Failed to connect to camera #12

atirage opened this issue Feb 12, 2019 · 10 comments
Labels
bug Something isn't working

Comments

@atirage
Copy link

atirage commented Feb 12, 2019

I'm getting the following error while connecting to a camera:

ERROR : onvif: TypeError: profiles.forEach is not a function
ERROR : onvif: at Camera.parseProfiles (/home/pi/.mozilla-iot/addons/onvif-adapter/node_modules/onvif-nvt/lib/camera.js:645:14)
ERROR : onvif: at media.getProfiles.then.results (/home/pi/.mozilla-iot/addons/onvif-adapter/node_modules/onvif-nvt/lib/camera.js:631:34)
ERROR : onvif: at
ERROR : onvif: at process._tickCallback (internal/process/next_tick.js:189:7)
ERROR : onvif: TypeError: profiles.forEach is not a function
ERROR : onvif: at Camera.parseProfiles (/home/pi/.mozilla-iot/addons/onvif-adapter/node_modules/onvif-nvt/lib/camera.js:645:14)
ERROR : onvif: at media.getProfiles.then.results (/home/pi/.mozilla-iot/addons/onvif-adapter/node_modules/onvif-nvt/lib/camera.js:631:34)
ERROR : onvif: at
ERROR : onvif: at process._tickCallback (internal/process/next_tick.js:189:7)

As sou can see from the log I'm using the Mozilla IoT Gateway and the camera I'm using is a Raspberry Pi camera made ONVIF compatible using https://github.com/BreeeZe/rpos.

@hawkeye64
Copy link
Owner

hawkeye64 commented Feb 12, 2019

Sounds like the Camera doesn't have profiles. Are you sure the camera is ONVIF compliant? If so, does it just have one profile that is not kept in an array?
Ok, I'll have to look into rpos and see if they are doing it right.

@atirage
Copy link
Author

atirage commented Feb 12, 2019

I've added some extra logging, this is what your parseProfiles gets as argument:
{ '$': { token: 'profile_token',
'xmlns:tt': 'http://www.onvif.org/ver10/schema' },
Name: 'CurrentProfile',
VideoSourceConfiguration:
{ '$': { token: 'video_src_config_token' },
Name: 'Primary Source',
UseCount: '0',
SourceToken: 'video_src_token',
Bounds: { '$': [Object] } },

VideoEncoderConfiguration:
{ '$': { token: 'encoder_config_token' },
Name: 'PiCameraConfiguration',
UseCount: '0',
Encoding: 'H264',
Resolution: { Width: '1280', Height: '720' },
Quality: '1',
RateControl:
{ FrameRateLimit: '25',
EncodingInterval: '1',
BitrateLimit: '10000' },
H264: { GovLength: '60', H264Profile: 'High' },
Multicast: { Address: [Object], Port: '0', TTL: '1', AutoStart: 'false' },
SessionTimeout: 'PT1000S' },

PTZConfiguration:
{ '$': { token: 'ptz_config_token_0' },
Name: 'PTZ Configuration',
UseCount: '1',
NodeToken: 'ptz_node_token_0',
DefaultAbsolutePantTiltPositionSpace: 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace',
DefaultAbsoluteZoomPositionSpace: 'http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace',
DefaultRelativePanTiltTranslationSpace: 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace',
DefaultRelativeZoomTranslationSpace: 'http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace',
DefaultContinuousPanTiltVelocitySpace: 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace',
DefaultContinuousZoomVelocitySpace: 'http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace',
DefaultPTZSpeed: { PanTilt: [Object], Zoom: [Object] },
DefaultPTZTimeout: 'PT5S' }
}

@mijapa
Copy link

mijapa commented Mar 7, 2019

I have similar error using the Mozilla IoT Gateway and the camera I'm using is Android phone camera made ONVIF compatible using IP Webcam https://play.google.com/store/apps/details?id=com.pas.webcam

ERROR : onvif: TypeError: Cannot read property 'forEach' of undefined
ERROR : onvif: at core.getScopes.then.results (/home/mp/.mozilla-iot/addons/onvif-adapter/node_modules/onvif-nvt/lib/camera.js:562:18)
ERROR : onvif: at
ERROR : onvif: at process._tickCallback (internal/process/next_tick.js:189:7)
ERROR : onvif: TypeError: Cannot read property 'forEach' of undefined
ERROR : onvif: at core.getScopes.then.results (/home/mp/.mozilla-iot/addons/onvif-adapter/node_modules/onvif-nvt/lib/camera.js:562:18)
ERROR : onvif: at
ERROR : onvif: at process._tickCallback (internal/process/next_tick.js:189:7)
ERROR : onvif: Failed to initialize device at undefined: TypeError: Cannot read property 'forEach' of undefined

@hawkeye64
Copy link
Owner

Thanks for the info. I have an Android I can use to replicate this and get it fixed (hopefully).

@hawkeye64 hawkeye64 added the bug Something isn't working label Apr 2, 2019
@atirage
Copy link
Author

atirage commented Mar 21, 2020

Any update on this? I'm no js expert, but to me this looks like a type mismatch: rpos provides an object, nvt expects an array.

@hawkeye64
Copy link
Owner

@atirage Sorry, have not had time. I apologize that this project is low on my list. We use it at work, but all of our cameras work with it. PRs are very welcomed if you feel you can help out. The problem with working with hardware is if you don't have the specific hardware, then you can only hope something works. This can cause several iterations with those that do have the hardware. Therefore, it's easier for those with the hardware do the specific work needed. Again, my apologies. Please feel free to work through it and make adjustments as needed. I also just want to point out, that having done this project, I have found the ONVIF specs to be lenient on design and different camera manufacturers implement in different ways, unfortunately. If you make changes, be sure to keep compatibility with those cameras that currently do work. ie: test returned object as js array or js object.. Thanks.

@atirage
Copy link
Author

atirage commented Apr 4, 2020

@hawkeye64, no worries, I was just wondering if it was still on your radar or not. :)
I managed to fix it by adding the following code snippet in function parseProfiles:

if (!Array.isArray(profiles)) {
      var prof_arr = [];
      prof_arr[0] = profiles;
      profiles = prof_arr;
    }

I'm not sure if this is generic enough, but it seems that the issue will happen only if there's just one profile.

@hawkeye64
Copy link
Owner

@atirage Yes, it should probably detect if it is an object or an array. Can you PR the code?

slongiaru-dmind added a commit to slongiaru-dmind/onvif-nvt that referenced this issue Apr 8, 2020
Fix an issues caused when a single profile is given for a camera.
It fixes the issue: hawkeye64#12
@slongiaru-dmind slongiaru-dmind mentioned this issue Apr 8, 2020
@hawkeye64
Copy link
Owner

Will release soon

@hawkeye64
Copy link
Owner

Forgot to close after releasing, so closing now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants