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

can't receive data from Rpi, instead it show errors #94

Closed
Moha-alfridi opened this issue Apr 5, 2018 · 8 comments
Closed

can't receive data from Rpi, instead it show errors #94

Moha-alfridi opened this issue Apr 5, 2018 · 8 comments

Comments

@Moha-alfridi
Copy link

Moha-alfridi commented Apr 5, 2018

Hi @hamuchiwa.
So, after modifying the IP and the port on "collect_training_data.py" to my computer local IP and port, and running it on my computer terminal using python command, it ran without errors, and was waiting for the data to be sent from the RPi, so I used SSH and ran "stream_client.py" using python command, after changing it's IP and port to my computer IP & port.

My computer's Terminal show's

Start collecting images...
for couple of seconds ..

then it print these errors
Traceback (most recent call last): File "collect_training_data.py", line 172, in <module> CollectTrainingData() File "collect_training_data.py", line 35, in __init__ self.collect_image() File "collect_training_data.py", line 53, in collect_image stream_bytes += self.connection.read(1024) TypeError: must be str, not bytes

Line 72 on collect_training_data.py
CollectTrainingData()

Line 35 on collect_training_data.py
self.collect_image()

Line 53 on collect_training_data.py
stream_bytes += self.connection.read(1024)

and on the ssh terminal "RPi" it shows

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.732372] Internal error: Oops: 17 [#1] SMP ARM

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737360] Process python (pid: 922, stack limit = 0xab2fe210)

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737366] Stack: (0xab2ffd98 to 0xab300000)

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737373] fd80:                                                       000005a8 806d1930

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737384] fda0: 000076c8 ab2ffec0 ab060640 000076c8 ab2ffe54 ab2ffdc0 806d1950 806ce34c

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737395] fdc0: 000005a8 ab2ffdd0 804aeab8 b4dbbc00 80c069c4 80d0a08c 80c049c0 ab2fe000

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737405] fde0: 00000000 00000000 00000000 00000000 00000001 00000000 ab2ffe24 00000200

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737416] fe00: ab2ffec8 ab060790 000005a8 00000000 00000121 000005a8 7fffffff 3c334492

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737427] fe20: 801235c4 801e0000 ab060640 ab060640 0000b53e ab2ffec0 00000121 80108224

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737438] fe40: ab2fe000 00000000 ab2ffe74 ab2ffe58 806d247c 806d1654 806d2444 ab060640

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737448] fe60: 00000000 a4988fc0 ab2ffe94 ab2ffe78 806fe570 806d2450 802aa2ac 802aa200

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737459] fe80: 00000000 00000000 ab2ffea4 ab2ffe98 80657c84 806fe534 ab2fff8c ab2ffea8

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737469] fea0: 80658dd4 80657c6c ab2ffec8 80601cd4 fffffff7 00000001 01dd6d70 0000b53e

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737480] fec0: 00000000 00000000 00000001 000076c8 00003e76 ab2ffeb8 00000001 801ee204

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737490] fee0: 00000000 00000000 00000000 ab2ffef8 80101850 80123188 ab2fff1c ab2fff08

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737501] ff00: 00000001 00400000 80c0469c 8017a1b0 ab2fff34 ab2fff20 8017a1b0 80179dec

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737511] ff20: 8017a08c 80c0469c ab2fff44 ab2fff38 80174f10 804ae66c ab2fff5c ab2fff48

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737522] ff40: 804ae66c 804ae590 804ae630 8012377c ab2fff6c ab2fff60 8012377c 801845dc

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737533] ff60: ab2fff94 ab2fff70 80175554 801236e0 ab2fffb0 7ea748b8 76a57780 7ea748b8

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737544] ff80: ab2fffa4 ab2fff90 80658e24 80658d18 00000000 00000000 00000000 ab2fffa8

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737555] ffa0: 80108080 80658e08 7ea748b8 76a57780 00000004 01dd6d70 0000b53e 00000000

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737565] ffc0: 7ea748b8 76a57780 7ea748b8 00000121 00000000 00000000 00000001 01c91ae8

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737576] ffe0: 00000000 7ea74850 00000000 76eb8984 80000010 00000004 aaaaaaaa aaaaaaaa

Message from syslogd@raspberrypi at Apr  5 22:22:58 ...
 kernel:[   85.737714] Code: e155000c 03a05000 e2117902 1a000039 (e5d50028)

I appreciate your help, God bless u

@hamuchiwa
Copy link
Owner

I think this is because Python3 handles str and bytes differently, change line 50 stream_bytes = ' ' to stream_bytes = b' ', hope this will fix the issue.

@Moha-alfridi
Copy link
Author

Thanks for the response ..

it still showing error even thou after changing line 50

Traceback (most recent call last): File "/Users/moha/PycharmProjects/AutoRCCar/test/stream_server_test.py", line 44, in <module> VideoStreamingTest() File "/Users/moha/PycharmProjects/AutoRCCar/test/stream_server_test.py", line 16, in __init__ self.streaming() File "/Users/moha/PycharmProjects/AutoRCCar/test/stream_server_test.py", line 27, in streaming stream_bytes += self.connection.read(1024) TypeError: must be str, not bytes

@hamuchiwa
Copy link
Owner

Every file handles streaming contains this line stream_bytes = ' ' , so after changing that line in stream_server_test.py, it still gives you error? Can you also check the type of self.connection.read(1024)?

@Moha-alfridi
Copy link
Author

Will I did what you ask for both of the collecting data files. the stream_server_test.py
show this error ..

Connection from: ('192.168.1.195', 53440) Streaming... Press 'q' to exit Traceback (most recent call last): File "stream_server_test.py", line 44, in <module> VideoStreamingTest() File "stream_server_test.py", line 16, in __init__ self.streaming() File "stream_server_test.py", line 28, in streaming first = stream_bytes.find('\xff\xd8') TypeError: a bytes-like object is required, not 'str'

and the collect_training_data.py file show this error ..

Start collecting images... Traceback (most recent call last): File "collect_training_data.py", line 172, in <module> CollectTrainingData() File "collect_training_data.py", line 35, in __init__ self.collect_image() File "collect_training_data.py", line 54, in collect_image first = stream_bytes.find('\xff\xd8') TypeError: a bytes-like object is required, not 'str'

I tried to run them over the terminal and the PyCharm but the same error are showing, and for your question Can you also check the type of self.connection.read(1024)? I didn't get what you mean. Can you explain more please.,

@hamuchiwa
Copy link
Owner

Okay, a few more changes, Python3 treats '\xff\xd8' as string, so change it to b'\xff\xd8' instead. In Python2, bytes and str are interchangeable.
I wanted to ask you to check the type of the object like this:

temp = self.connection.read(1024)
print(type(temp))

But it seems the error you provided says it already - TypeError: a bytes-like object...

@Moha-alfridi
Copy link
Author

So, I was able to print the type of the stream_bytes, and a new error came up

`Connection from: ('192.168.1.195', 53458)
Streaming...
Press 'q' to exit
<class 'bytes'>

<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
Traceback (most recent call last):
File "/Users/moha/PycharmProjects/AutoRCCar/test/stream_server_test.py", line 45, in
VideoStreamingTest()
File "/Users/moha/PycharmProjects/AutoRCCar/test/stream_server_test.py", line 16, in init
self.streaming()
File "/Users/moha/PycharmProjects/AutoRCCar/test/stream_server_test.py", line 34, in streaming
image = cv2.imdecode(np.fromstring(jpg, dtype=np.uint8), cv2.CV_LOAD_IMAGE_GRAYSCALE)
AttributeError: module 'cv2.cv2' has no attribute 'CV_LOAD_IMAGE_GRAYSCALE'
<class 'bytes'>`

@Moha-alfridi
Copy link
Author

I forgot to include the error that cam from the Rpi thru the SSH

`Traceback (most recent call last):
File "stream_client.py", line 31, in
connection.flush()
File "/usr/lib/python3.5/socket.py", line 594, in write
return self._sock.send(b)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "stream_client.py", line 40, in
connection.close()
File "/usr/lib/python3.5/socket.py", line 594, in write
return self._sock.send(b)
BrokenPipeError: [Errno 32] Broken pipe`

@Moha-alfridi
Copy link
Author

So, I was trying to figure out the error that I had, and came across a solution here https://stackoverflow.com/questions/19013961/cv2-imread-flags-not-found

So for future reference for this error
AttributeError: module 'cv2.cv2' has no attribute 'CV_LOAD_IMAGE_GRAYSCALE'
you should go ahead to line 33 where it shows
image = cv2.imdecode(np.fromstring(jpg, dtype=np.uint8), cv2.CV_LOAD_IMAGE_GRAYSCALE)
and change the CV_LOAD_IMAGE_GRAYSCALE with cv2.IMREAD_COLOR for color stream
the whole line should be like
image = cv2.imdecode(np.fromstring(jpg, dtype=np.uint8), cv2.cv2.IMREAD_COLOR)

and this will show the video stream in gray by using cv2.IMREAD_GRAYSCALE
the whole line should be like
image = cv2.imdecode(np.fromstring(jpg, dtype=np.uint8), cv2.cv2.IMREAD_GRAYSCALE)

@hamuchiwa thank you for your help, best wishes . . .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants