IpCamera: New IP Camera Binding

Tags: #<Tag:0x00007fc3f797e830> #<Tag:0x00007fc3f797e218> #<Tag:0x00007fc3f797e128>

Sure, but I have been over my code so many times since I had a few reports and it would have to only occur under certain situations for it to have slipped through. I have used Visual VM to analise the binding for memory leaks in an Openhab 2.2 runtime using Eclipse IDE…

The binding does not do a single thing different when a UI is opened. As far as the binding goes it will fetch an image and place it in the IMAGE item which is part of the openhab framework, then the UI will fetch the image from the IMAGE item which is all openhab code and not mine. If it only occurs when you open Basic UI then it could be a bug in the openhab framework, or it may be an issue with garbage clean up. Perhaps try some of the following ideas to see if you see a pattern…

  1. Does it happen if you have all UI closed and only use paperUI control tab to watch the picture?
  2. Does stopping the image from updating in the bindings settings change anything?
  3. Does it occur when using the Android app on a tablet or phone?
  4. What happens with only 1 Camera? 2 cams, 3… Is it only when you increase the amount of cameras, or use a certain model?

Also if you get an out of memory error with this active

EXTRA_JAVA_OPTS="-XX:+HeapDumpOnOutOfMemoryError -Xmx512m"

It will create a memory dump file that you can open and analyze with a program like Visual VM or Eclipse MAT that will tell you what it causing the memory to fill up.

Any chance we could get this binding to support saving the image to file, rather than an image item?

Bindings like the Pushover Action don’t support image items natively.

Cross posted on a Pushover thread:

I am trying to use the IPcamera binding to capture movement at the front door - then send the notification to my phone / watch.

Pushover is a tidy solution, since it can display the imageon my watch if needed :slight_smile:
Thanks

Nice post - can you tell me where the memory dump goes please?

I believe they will go into your user-data folder. The location was setup as a samba share in openhabian so it was easy to find as the file is large and I think had a extension of .hprof
I noticed in a forum post here that you can create a heap dump using the openhab console using this command, it may output to a zip file…

dev:dump-create

PR are welcome as that would be a simple change, but I don’t have the time to add such a feature. That is possibly a good idea for a standalone “helper” binding that could be created similar to the expire binding if there are other use cases for it… I am currently “playing” with a new feature for this binding and that is the ability to “ECHO” serve files. Basic idea is the binding is a http server and it can detect how many clients are connected to it and will only fetch the picture or a video stream when a UI is asking for it. This would mean for cameras that can not have authentication disabled or have a connection limit like Foscam it would open up more options as you use URLs from the bindings and not from the camera. Does this pose another solution to you? is the issue authentication or the need for an actual file?

My Intro: IP camera n00b

@matt1

From the list of cameras in your binding documentation, I cannot tell if cameras such as the WyzeCam (Xiaomi Xiaofang) or WyzeCam Pan (Xiaomi Dafang) are compatible with your binding. I don’t know if those cameras are ONVIF compatible… even with the OpenIPC or the Dafang Hacks firmware flashed on them (it only mentions RTSP).

I’m looking to deploy several cameras and looking for a cost effective (i.e., cheap) approach. Those cameras seem like good options in that sense. And, for all the reasons why I have openHAB in the first place, I want to keep control of the cameras localized (i.e., not on the camera vendor’s cloud or subscription).

If the answer to my camera question is no, is there a comparable line of inexpensive cameras that are compatible with your binding?

Thanks.

Mike

No one has reported if they work so I have no idea other than they will not have motion alarms and other features as they do not have an API afaik. If they have a snapshot URL that works then u possibly may get a picture.
I should stress that this binding is NOT an ONVIF binding, to be called that it needs to pass tests and support a minimum set of features, the same goes for cameras. Sadly the onvif tests are not independently tested/verified, so even if a camera claims it is ONVIF if the price tag of the camera is too low expect it to not really be 100% onvif without issues. A camera can pass onvif v1.0 spec and still advertise it is onvif…
This binding only uses ONVIF for moving the camera with absolutue PTZ movements, there are two more types of ONVIF movements which are not implemented currently as they are not as useful in an openhab setup. The other thing it does is via ONVIF asks a camera what link to use for a snapshot and RTSP feeds, but currently the binding does not do RTSP. It is a long way from being able to call itself onvif and I have no plans to do that.

Check this post out, you may be able to use the same method to get RTSP feed with those cheap cameras you listed, but you still will have no alarm features without setting up a server using the software in my first post.

The foscam C1 (non lite model) is 4x the price and will give night vision and PIR sensor so will be far better against false movement alarms. The lite model is only 2x the price and has no night vision compared to WyzeCam.

WyzeCam Pan seems pretty close to what you can get Amcrest PTZ cameras for. Amcrest appears to be made by Dahua the second biggest ip camera manufacturer after Hikvision and the firmware seems good from what I have used so far.

I see it as silly to look at it as 2 or 4 times the price, instead consider it as an extra $50 per camera to save you from needing to spend a few hundred on a server to get video motion alarms and a lot easier setup in Openhab. Plus you may just get extra features in the camera like a better quality night vision picture or PIR sensors. Sometimes spending a little more is better value and a whole lot less headaches.

Thanks for the detailed response.

True - you get what you pay for… and sometimes you pay for what you get :wink:

I’ll add your information to my research file. I have a couple other projects I want to tackle before I get to deploying cameras and integration to my openHAB instance.

Cheers!

Mike

This is great work, thanks.
Works great on my cheapo Sannce / Annke cams. Can get the Onvif paths using iSpy or the soutcefourge onvif app.
It is a little resource intensive though - kinda grinds my RaspberryPi in to the ground.

For now, I simple have an external PIR motion detector and run Ffmpeg using exec binding to snapshot and forward images via Pushover when needed.
I’ll be keeping tabs on this binding though and will re-install when I upgrade my hardware.

Thanks for the hard work

1 Like

Hi @matt1

I just back to tesitng of Dahua IP cam with IPC-HFW4431R-Z

On begnigng screenshot form Cam was working but after some time is not any more updated

Coudl you please look why ?

Please see first log:

> 2018-09-10 19:16:33.506 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.2.10, 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.507 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Just locked in main1
> 2018-09-10 19:16:33.509 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Just unlocked main1
> 2018-09-10 19:16:33.511 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 7 channels tracked (some of these may be closed).
> 2018-09-10 19:16:33.515 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.516 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have re-opened  the closed channel:1 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.518 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.2.10, 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.519 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Just locked in main1
> 2018-09-10 19:16:33.521 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Just unlocked main1
> 2018-09-10 19:16:33.524 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 7 channels tracked (some of these may be closed).
> 2018-09-10 19:16:33.528 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.530 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have re-opened  the closed channel:2 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.547 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - 401: Normal for DIGEST authorization. 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.549 [DEBUG] [ipcamera.internal.MyNettyAuthHandler] - 401: Mark as closing, the  channel:1 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.553 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Resending using a fresh DIGEST 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.555 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.2.10, 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.558 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Just locked in main1
> 2018-09-10 19:16:33.560 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Just unlocked main1
> 2018-09-10 19:16:33.561 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - 401: Normal for DIGEST authorization. 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.563 [DEBUG] [ipcamera.internal.MyNettyAuthHandler] - 401: Mark as closing, the  channel:2 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.565 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Resending using a fresh DIGEST 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.565 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 7 channels tracked (some of these may be closed).
> 2018-09-10 19:16:33.567 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.2.10, 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.569 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Just locked in main1
> 2018-09-10 19:16:33.569 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.571 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Just unlocked main1
> 2018-09-10 19:16:33.574 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 7 channels tracked (some of these may be closed).
> 2018-09-10 19:16:33.574 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have re-opened  the closed channel:4 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.578 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.580 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have re-opened  the closed channel:5 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.580 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
> HTTP/1.1 401 Unauthorized
> WWW-Authenticate: Digest realm="Login to 3L08221PAA35018", qop="auth", nonce="1974546864", opaque="0ad03079faa3a901586f69bd4837dc33cfadeeb1"
> Connection: close
> CONTENT-LENGTH: 0
> 2018-09-10 19:16:33.583 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
> HTTP/1.1 401 Unauthorized
> WWW-Authenticate: Digest realm="Login to 3L08221PAA35018", qop="auth", nonce="1934386125", opaque="0ad03079faa3a901586f69bd4837dc33cfadeeb1"
> Connection: close
> CONTENT-LENGTH: 0
> 2018-09-10 19:16:33.585 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel marked as closing, channel:2 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.586 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Message passed on from new code, must be EmptyLastHttpContent
> 2018-09-10 19:16:33.586 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel marked as closing, channel:1 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.588 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - EmptyLastHttpContent
> 2018-09-10 19:16:33.590 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:2 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.591 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Message passed on from new code, must be EmptyLastHttpContent
> 2018-09-10 19:16:33.592 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Closing CommonCameraHandler. 		URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.595 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - EmptyLastHttpContent
> 2018-09-10 19:16:33.598 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:1 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.600 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Closing CommonCameraHandler. 		URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.633 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
> HTTP/1.1 400 Bad Request
> Connection: close
> Content-type: text/plain;charset=utf-8
> Content-Length: 21
> 2018-09-10 19:16:33.635 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel marked as closing, channel:4 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.636 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Message passed on from new code, must be EmptyLastHttpContent
> 2018-09-10 19:16:33.638 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 21, cap: 21/21, unwrapped: PooledUnsafeDirectByteBuf(ridx: 128, widx: 128, cap: 1024)), decoderResult: success)
> 2018-09-10 19:16:33.641 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is 	:Error
> Bad Request!
> :
> 2018-09-10 19:16:33.641 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
> HTTP/1.1 400 Bad Request
> Connection: close
> Content-type: text/plain;charset=utf-8
> Content-Length: 21
> 2018-09-10 19:16:33.643 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel marked as closing, channel:5 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.645 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Message passed on from new code, must be EmptyLastHttpContent
> 2018-09-10 19:16:33.645 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:4 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.646 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 21, cap: 21/21, unwrapped: PooledUnsafeDirectByteBuf(ridx: 128, widx: 128, cap: 1024)), decoderResult: success)
> 2018-09-10 19:16:33.647 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Closing CommonCameraHandler. 		URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.648 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is 	:Error
> Bad Request!
> :
> 2018-09-10 19:16:33.651 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:5 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.652 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Closing CommonCameraHandler. 		URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.685 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 566, cap: 566/566, unwrapped: PooledUnsafeDirectByteBuf(ridx: 566, widx: 566, cap: 2048)), decoderResult: success)
> 2018-09-10 19:16:33.687 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is 	:--boundary
> Content-Type: application/xml; charset="UTF-8"
> Content-Length: 483

Your log is only 180ms long and does not show when the camera trys to fetch a picture.
The only interesting thing I see is the 400 bad request, which is probably because the feature being checked does not exsist on your camera ie it has no mic and hence no audio alarm.

I would need some log output showing where the picture URL is shown, if you do not see this happening it could be you have set the camera to not update the picture which if you move the update picture now switch it should update a single time.

Hi matt1,

Thanks for clarificaiton, I will collect longer one trying more options avalible on camera (IVS, Face detecton zoom…)

Would this binding work with one the H264 DVRs?

Mike

@matt1

After settings checking i corrected issue with image.
In mean time i see in log very often:

> URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion

if this is checking of motion detection status then this is wrong as proper request should be

/cgi-bin/eventManager.cgi?action=getEventIndexes&code=VideoMotion

to get answer:
if motion detected

channels[0]=0

and if no detection

Error: No Events

I do not see any log concerning zoom function, could you tell me how it’s realized?
This cam is not PTZ but varifocal.

after investigation: all below are working for varifocal cam

I found autofocus option:

/cgi-bin/devVideoInput.cgi?action=autoFocus

result:

OK

Zoom in max:

/cgi-bin/devVideoInput.cgi?action=adjustFocus&focus=0.990000&zoom=1.000000

Zoom out max

/cgi-bin/devVideoInput.cgi?action=adjustFocus&focus=0.090000&zoom=0.000000

Result always
OK

This is music to my ears.

I’m just starting out with my IP camera setup and Blue Iris was coming out on top (versus a Hikvision NVR and their own software).

What hardware are you using to run Blue Iris?

@luckymallari

What model cameras are supported?

What Blue Iris software has to be acquired? Is there a “personal use” license or are the only options the LE (1 camera) and Full versions?

I don’t see an ONVIF openHAB binding specifically. What binding do you use in openHAB? Do you have examples of your declarations (Things, Items, Rules, etc.)?

Thank you for the information.

Mike

I’m running a rig with i7-2600. Im using direct to disk recording, and my CPU averages at 40% only. This is with 16 cameras, 8 of which are 4K cameras. The rest are 1080P.

@Mike, you should lookup the BlueIris docs. There are literally HUNDREDS of cameras supported, and any camera with proper/correct ONVIF.

Current BlueIris supports MQTT and REST. BlueIRIS itself also has a REST API, which you can call from openHAB

That’s what I needed. Thanks.

Now on to making a decision on camera equipment…

@mjcumming
No idea, if it supports the API then it should work. Hikvision, dahua and amcrest have APIs that allow for use behind a NVR but potentially not all features will work behind the NVR and that is up to how well supported and bug free the company has written the firmware.

@Kristo
Your url links look more like AMCREST api so try setting the camera up as an Amcrest as they are made by Dahua and it is possible that will work. Dahua now appears to use an event stream for alarms and not the method you described.

@matt1

Thank’s for advise i will try Amcrest,
Links which i provided are comming form Dahua API version 1,67

You need to connect to the camera with ONVIF for any of the Pan Tilt or Zoom features to work, some cameras have ONVIF disabled by default in their settings and you also need to work out what port number it will need to be set to.

As for the motion detection try this link in a browser. See if I made a mistake in its format and what needs to be changed to make it work…

http://ipaddresshere/cgi-bin/eventManager.cgi?action=attach&codes=[VideoMotion,MDResult,VideoBlind,VideoLoss,CrossLineDetection]&channel=[0]

This is described on page 62 under 6.10 Attach
The advantage of using this method is the camera only creates traffic when an alarm goes off as openhab/binding does not need to keep polling asking if the alarm has gone off. If your camera has advanced alarms like FaceDetection this allows the binding to be able to react.

I have checked and the Amcrest url is identical to what you were asking for, however the above method is far better if your camera supports it and if I did not get the url format wrong. I need someone with a Dahua camera to test and give feedback on a few things as I dont own one.