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

Socket Error #25

Closed
ghost opened this issue Dec 3, 2020 · 8 comments · Fixed by #26
Closed

Socket Error #25

ghost opened this issue Dec 3, 2020 · 8 comments · Fixed by #26
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Dec 3, 2020

Hi, i get an Error when i start camera.py

`pi@raspberrypi:~/tflite/examples $ python3 mytest.py
Login success
Getting information [{'cmd': 'GetDevInfo', 'code': 0, 'value': {'DevInfo': {'B485': 0, 'IOInputNum': 0, 'IOOutputNum': 0, 'audioNum': 1, 'buildDay': 'build 20103104', 'cfgVer': 'v3.0.0.0', 'channelNum': 1, 'detail': 'IPC_51516M5MS10E1W31100000001', 'diskNum': 1, 'firmVer': 'v3.0.0.116_20103104', 'frameworkVer': 1, 'hardVer': 'IPC_51516M5M', 'model': 'RLC-511W', 'name': 'Pond', 'pakSuffix': 'pak,paks', 'serial': '00000000065536', 'type': 'IPC', 'wifi': 1}}}]
Error connecting to SOCKS5 proxy 127.0.0.1:8000: [Errno 111] Connection refused
Error connecting to SOCKS5 proxy 127.0.0.1:8000: [Errno 111] Connection refused
'NoneType' object has no attribute 'send'
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/api/recording.py", line 44, in open_video_stream
rtsp_client.preview()
File "/home/pi/.local/lib/python3.7/site-packages/RtspClient.py", line 78, in preview
cv2.imshow(win_name, self.get_frame())
cv2.error: OpenCV(4.4.0) /tmp/pip-wheel-2l8ccy47/opencv-python/opencv/modules/highgui/src/window.cpp:376: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "mytest.py", line 5, in
c.open_video_stream()
File "/home/pi/.local/lib/python3.7/site-packages/api/recording.py", line 44, in open_video_stream
rtsp_client.preview()
File "/home/pi/.local/lib/python3.7/site-packages/RtspClient.py", line 34, in exit
self.sockt.close()
AttributeError: 'NoneType' object has no attribute 'close'

@themoosman
Copy link
Contributor

It means your OpenCV isn't configured correctly. I had similar errors and ended up building OpenCV from source and that worked.

@Benehiko
Copy link
Member

Benehiko commented Dec 3, 2020

@Portscanner This seems more like you're connecting to the camera over SOCKS5 and cannot retrieve the frame you requested (hence the OpenCV error). Could you give me a more detailed description of your setup and maybe some code (where you are calling and using the reolink-api library).

@ghost
Copy link
Author

ghost commented Dec 3, 2020

I have a Raspberry Pi 4 with a Coral-Accelerator attached. I followed the instructions below:
https://gilberttanner.com/blog/google-coral-usb-accelerator-introduction
and
https://github.com/pmcbride/coral-webcam-detection/blob/master/my_classify_capture.py
and
https://github.com/EdjeElectronics/TensorFlow-Lite-Object-Detection-on-Android-and-Raspberry-Pi/blob/master/Raspberry_Pi_Guide.md

Now I try to read the Camera Frames directly via the Reolink Camera:
from Camera import Camera
c = Camera ("192.168.1.44", "admin", "123456")
print ("Getting information", c.get_information ())
c.open_video_stream ()

I can't get any further.

@Benehiko
Copy link
Member

Benehiko commented Dec 4, 2020

It might be a versioning issue. Did you install the pypi package or import directly from github?
I have now updated the pypi package to version 0.0.4 which should include the update @themoosman made to the rtsp streaming service.

@Benehiko Benehiko added the bug Something isn't working label Dec 4, 2020
@themoosman
Copy link
Contributor

themoosman commented Dec 4, 2020

It might be a versioning issue. Did you install the pypi package or import directly from github?
I have now updated the pypi package to version 0.0.4 which should include the update @themoosman made to the rtsp streaming service.

That's a good point, I forgot my RTSP changes aren't in the released pypi package.

@ghost
Copy link
Author

ghost commented Dec 4, 2020

Excellent, I'm getting a stream now. But there are many error messages.

Login success
Getting information [{'cmd': 'GetDevInfo', 'code': 0, 'value': {'DevInfo': {'B485': 0, 'IOInputNum': 0, 'IOOutputNum': 0, 'audioNum': 1, 'buildDay': 'build 20103104', 'cfgVer': 'v3.0.0.0', 'channelNum': 1, 'detail': 'IPC_51516M5MS10E1W31100000001', 'diskNum': 1, 'firmVer': 'v3.0.0.116_20103104', 'frameworkVer': 1, 'hardVer': 'IPC_51516M5M', 'model': 'RLC-511W', 'name': 'Pond', 'pakSuffix': 'pak,paks', 'serial': '00000000065536', 'type': 'IPC', 'wifi': 1}}}]
[h264 @ 0x1148450] error while decoding MB 128 116, bytestream -5
[h264 @ 0xea5d10] error while decoding MB 108 80, bytestream -5
[h264 @ 0xe20780] error while decoding MB 12 83, bytestream -5
[h264 @ 0x1148450] error while decoding MB 53 112, bytestream -7
[h264 @ 0xea5d10] error while decoding MB 14 113, bytestream -5
[h264 @ 0xe1ee30] error while decoding MB 9 111, bytestream -7
[h264 @ 0xe1ee30] error while decoding MB 28 107, bytestream -5
[h264 @ 0xe20780] error while decoding MB 11 85, bytestream -5
[h264 @ 0x1148450] left block unavailable for requested intra4x4 mode -1
[h264 @ 0x1148450] error while decoding MB 0 13, bytestream 19905
[h264 @ 0xe20780] error while decoding MB 126 85, bytestream -5
[h264 @ 0xe20780] error while decoding MB 67 55, bytestream -11
[h264 @ 0xea5d10] cabac decode of qscale diff failed at 47 119
[h264 @ 0xea5d10] error while decoding MB 47 119, bytestream 20347
[h264 @ 0xe1ee30] cabac decode of qscale diff failed at 156 55
[h264 @ 0xe1ee30] error while decoding MB 156 55, bytestream -5
[h264 @ 0x1148450] error while decoding MB 7 86, bytestream -5
[h264 @ 0x1148450] error while decoding MB 9 47, bytestream -15
[h264 @ 0xe20780] error while decoding MB 40 52, bytestream -5
[h264 @ 0x1148450] error while decoding MB 17 84, bytestream -5
[h264 @ 0xe1ee30] error while decoding MB 10 83, bytestream -5
[h264 @ 0xe20780] error while decoding MB 93 115, bytestream -5
etc......

EDIT: When I restart the Camera, there are no Errors

@Benehiko
Copy link
Member

Benehiko commented Dec 4, 2020

@Portscanner These errors seem to be more related to the OpenCV VideoCapture method which is in use in our RTSP client https://github.com/Benehiko/ReolinkCameraAPI/blob/25ce2cbb555e046efa4b6aaa76a35add02bafff2/RtspClient.py#L36

There seems to be a thread on how to solve this.
https://stackoverflow.com/questions/49233433/opencv-read-errorh264-0x8f915e0-error-while-decoding-mb-53-20-bytestream

@themoosman I think we need to remove the imshow method here and return the frames in a non-blocking fashion so the user could do with it what they want. https://github.com/Benehiko/ReolinkCameraAPI/blob/25ce2cbb555e046efa4b6aaa76a35add02bafff2/RtspClient.py#L40

Benehiko added a commit that referenced this issue Dec 4, 2020
This might fix the stream errors in issue #25
Also refactored the code a bit since we do not want to display a window from within the API (offload to the person implementing it).
@Benehiko
Copy link
Member

Benehiko commented Dec 4, 2020

@themoosman I've updated the RTSP client with a non-blocking and blocking method (so the client can choose based on their config). The API should work on the camera and can be tested using the example file I made https://github.com/Benehiko/ReolinkCameraAPI/blob/dev/examples/streaming_video.py

I tested it on a video file, but not sure if it will work on the camera stream.

@Portscanner if you are daring enough, checkout the dev branch and use the API directly from github instead of pypi. I can update as you get issues. Will release to v0.0.5 once tested by @themoosman

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

Successfully merging a pull request may close this issue.

2 participants