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

module 'zmq' has no attribute '0' #45

Closed
Julius-ZCJ opened this issue Aug 20, 2019 · 8 comments
Closed

module 'zmq' has no attribute '0' #45

Julius-ZCJ opened this issue Aug 20, 2019 · 8 comments
Assignees
Milestone

Comments

@Julius-ZCJ
Copy link

@Julius-ZCJ Julius-ZCJ commented Aug 20, 2019

When I use NetGear, I got this error: module 'zmq' has no attribute '0'
I install pyzmp==17.1.2
numpy ==1.15.4
OpenCV-contirb-python==3.4.2.16
vidgear==0.1.5

And I run this server in container base ubuntu16.04

here is my code:

# import libraries
from vidgear.gears import NetGear
import cv2

stream = cv2.VideoCapture('hamilton_clip.mp4') #Open any video stream

options = {'flag': '0', 'copy': False, 'track': False}
#change following IP address '192.168.1.xxx' with yours
server = NetGear(address = '192.168.10.189', port = '5454', protocol = 'tcp',  pattern = 0, receive_mode = False, logging = True, **options) #Define netgear server at your system IP address.

# infinite loop until [Ctrl+C] is pressed
while True:
	try: 
		(grabbed, frame) = stream.read()
		# read frames

		# check if frame is not grabbed
		if not grabbed:
			#if True break the infinite loop
			break

		# do something with frame here

		# send frame to server
		server.send(frame)
	
	except KeyboardInterrupt:
		#break the infinite loop
		break

# safely close video stream
stream.release()
# safely close server
writer.close()

it come from netgear demo

@abhiTronix abhiTronix self-assigned this Aug 20, 2019
@abhiTronix abhiTronix added this to the v0.1.6 milestone Aug 20, 2019
@abhiTronix

This comment has been minimized.

Copy link
Owner

@abhiTronix abhiTronix commented Aug 20, 2019

@Julius-ZCJ Thanks for reporting this bug. As temporary workaround Kindly remove flag attribute for now (as it's useless in current scenario) from **options dict which then becomes:

options = {'copy': False, 'track': False} //without `flag`

Also, I'm push fix for this bug in development branch shortly. Stay tuned.

@abhiTronix abhiTronix pinned this issue Aug 20, 2019
@Julius-ZCJ

This comment has been minimized.

Copy link
Author

@Julius-ZCJ Julius-ZCJ commented Aug 20, 2019

Thank you for your reply. I modify it now, but I meet some other errors:
1).when I use NetGear frist demo, using sever and client in same container, I got this error:
AttributeError: 'NetGear' object has no attribute 'id' (this error raise in client)
2).when I use NetGear second demo, using server and client in differ container, using tcp connect, I got follow error:
zmq.error.ZMQError: Cannot assign requested address
ValueError: Failed to bind address: tcp://192.168.1.xxx: xxxx and pattern: 0! Kindly recheck all parameters.(this also raise in client)

it tell me my address is error, I can't connect my server ,what can I do to solve this problem?

@abhiTronix

This comment has been minimized.

Copy link
Owner

@abhiTronix abhiTronix commented Aug 20, 2019

1).when I use NetGear frist demo, using sever and client in same container, I got this error:
AttributeError: 'NetGear' object has no attribute 'id' (this error raise in client)

@Julius-ZCJ This bug is already been fixed in the development branch, I'm posting related instructions shortly. As a workaround, you can enable logging=True in Netgear Class as follows:

client = NetGear(receive_mode = True, logging = True)

2).when I use NetGear second demo, using server and client in differ container, using tcp connect, I got follow error:
zmq.error.ZMQError: Cannot assign requested address
ValueError: Failed to bind address: tcp://192.168.1.xxx: xxxx and pattern: 0! Kindly recheck all parameters.(this also raise in client)

@Julius-ZCJ Kindly change address and port parameter to your Client's IP Address, you can use: hostname -I terminal command to know client's IP address and assign a unique Port address also.

@Julius-ZCJ

This comment has been minimized.

Copy link
Author

@Julius-ZCJ Julius-ZCJ commented Aug 20, 2019

@abhiTronix I have successed in first demo ,but I'm failed in second demo.
I run server in container, which ip is 172.17.0.8. And the container host ip is 192.169.1.149,
I mount port is 5454->5454, and my pc ip is 192.168.1.189

I run client in my pc, my pc ip is 192.168.1.189. So, what ip i could used in server, what ip i could used in client? I first use 172.17.0.8, and run client in same container with same ip, and I successed.
But when I run server in container with ip 172.17.0.8, and run client in my pc with ip 192.169.1.149
I always failed. I have tried to using container ip in client but it also failed. what can I do to make container can connect my pc?

@abhiTronix

This comment has been minimized.

Copy link
Owner

@abhiTronix abhiTronix commented Aug 20, 2019

but I'm failed in second demo.
I run server in container, which ip is 172.17.0.8. And the container host ip is 192.169.1.149,
I mount port is 5454->5454, and my pc ip is 192.168.1.189

I run client in my pc, my pc ip is 192.168.1.189. So, what ip i could used in server, what ip i could used in client? I first use 172.17.0.8, and run client in same container with same ip, and I successed.
But when I run server in container with ip 172.17.0.8, and run client in my pc with ip 192.169.1.149
I always failed. I have tried to using container ip in client but it also failed. what can I do to make container can connect my pc?

@Julius-ZCJ You have to use the Client's IP address on both client and server end, i.e 192.168.1.189 in your case since you are using this pc as a client.

abhiTronix added a commit that referenced this issue Aug 20, 2019
- Bug Fix for issue #45
- Added Feature to send data in mult-server mode #44
@abhiTronix

This comment has been minimized.

Copy link
Owner

@abhiTronix abhiTronix commented Aug 20, 2019

@Julius-ZCJ Kindly test development branch by strictly following steps and post your results here:

  1. Firstly, Kindly clone and install the testing branch as follows:
git clone git clone https://github.com/abhiTronix/vidgear.git
cd vidgear
git checkout testing
sudo pip install .
cd
  1. Then rerun the following updated algorithm for testing, but remember to change the IP address and port address with yours :

A. Server End:

Open the terminal on System-1 (Server) and execute the following python code. **Also, remember to write down the IP-address of Server by executing the command: 'hostname -I' and replace it in the following code:

# import libraries
from vidgear.gears import NetGear
import cv2

stream = cv2.VideoCapture('test.mp4') #Open any video stream

options = {flag : 0, copy : False, track : False}

#change following IP address '192.168.1.xxx' with yours
server = NetGear(address = '192.168.1.xxx', port = '5454', protocol = 'tcp',  pattern = 0, receive_mode = False, logging = True, **options) #Define netgear server at your system IP address.

# infinite loop until [Ctrl+C] is pressed
while True:
	try: 
		(grabbed, frame) = stream.read()
		# read frames

		# check if frame is not grabbed
		if not grabbed:
			#if True break the infinite loop
			break

		# do something with frame here

		# send frame to server
		server.send(frame)
	
	except KeyboardInterrupt:
		#break the infinite loop
		break

# safely close video stream
stream.release()
# safely close server
writer.close()

B. Client End:

Then open a terminal on the System-2(Client) and replace the IP address with Server's IP address and execute the following python code and see the output:

# import libraries
from vidgear.gears import NetGear
import cv2

options = {flag : 0, copy : False, track : False}

#change following IP address '192.168.1.xxx' with yours
client = NetGear(address = '192.168.1.xxx', port = '5454', protocol = 'tcp',  pattern = 0, receive_mode = True, logging = True, **options) #Define netgear client at Server IP address.

# infinite loop
while True:
	# receive frames from network
	frame = client.recv()

	# check if frame is None
	if frame is None:
		#if True break the infinite loop
		break

	# do something with frame here

	# Show output window
	cv2.imshow("Output Frame", frame)

	key = cv2.waitKey(1) & 0xFF
	# check for 'q' key-press
	if key == ord("q"):
		#if 'q' key-pressed break out
		break

# close output window
cv2.destroyAllWindows()
# safely close client
client.close()
abhiTronix added a commit that referenced this issue Aug 20, 2019
Enhancement: Introducing Multi-Server Mode and `PUB/SUB` messaging patterns in NetGear API
- Implemented Robust Multi-Server Compatibility support in NetGear.
- Implemented new Publish/Subscribe (`zmq.PUB/zmq.SUB`) patterns for seamless Live Streaming.
- Added ability to send additional data along with the frame in realtime.
- Updated ScreenGear to use Threaded Queue Mode by default.
- Removed redundant `THREADED_QUEUE_MODE` flag support from ScreenGear.
- Fixed issue #45 bugs.
@abhiTronix

This comment has been minimized.

Copy link
Owner

@abhiTronix abhiTronix commented Aug 20, 2019

Successfully Resolved & Merged in commit: 48c6a69

@Julius-ZCJ

This comment has been minimized.

Copy link
Author

@Julius-ZCJ Julius-ZCJ commented Aug 21, 2019

@abhiTronix Thank you vary much, I have solved this problem

@abhiTronix abhiTronix unpinned this issue Aug 21, 2019
@abhiTronix abhiTronix mentioned this issue Dec 24, 2019
5 of 7 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.