py-ic-imaging-control icon indicating copy to clipboard operation
py-ic-imaging-control copied to clipboard

Save_Image Error

Open dpalo325 opened this issue 7 years ago • 5 comments

Hi,

I'm currently attempting to run the demo.py, but I come across an error when attempting to save the file.

Specifically it prints the following error- “File "C:\Users\palod\Desktop\pyicic\IC_Camera.py", line 479, in save_image c_char_p(filename), TypeError: bytes or integer address expected instead of str instance”

I attempted to fix this by using the c_wchar_p instead, but this returns another error. I was wondering if you could offer any insight as to how I could possible alter this code/ what I need to do to get this demo to work properly. I am using a monochrome GigE camera, python 3, and I have not altered your code except for what is necessary. I am running this on windows 10, and I thought I should note that I do not currently have any light entering the camera, so it is receiving zero signal.

Thank you

dpalo325 avatar Dec 02 '17 00:12 dpalo325

Off the top of my head I'd guess this has something to do with Python 3 (I've only used this library with Python 2, which treats strings differently). You could try something like filename = b"your_filename" to ensure filename is a bytes array.

morefigs avatar Dec 02 '17 01:12 morefigs

Thank you for the fast response. Ok I will give that a try and if not I will attempt it on Python 2.

Thanks Again, Dylan Sent from Mail for Windows 10

From: morefigs Sent: Friday, December 1, 2017 5:38 PM To: morefigs/py-ic-imaging-control Cc: dpalo325; Author Subject: Re: [morefigs/py-ic-imaging-control] Save_Image Error (#25)

Off the top of my head I'd guess this has something to do with Python 3 (I've only used this library with Python 2, which treats strings differently). You could try something like filename = b"your_filename" to ensure filename is a bytes array. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

dpalo325 avatar Dec 02 '17 01:12 dpalo325

@dpalo325 Hi , I am getting the same error. Did you happen to resolve this or did you end up using it with Python 2.xx ?

nikhil4595 avatar Feb 04 '19 15:02 nikhil4595

Sorry, Python 3 wasn't tested with this lib. I don't intend to update this code or debug as I no longer use these cameras.

morefigs avatar Feb 05 '19 02:02 morefigs

I've just inherited an IC camera and trying to get it to work using spyder python 3.

The solution I found to this problem is to append the file name with .encode('utf-8').

So for the example on in the basic usage example in readme.md, change:

cam.save_image(''.join(['image-', str(i),'.jpg']), 1)

to

cam.save_image(''.join(['image-', str(i),'.jpg']).encode('utf-8'), 1)

and don't forget to add parentheses in the print commands.

matthims avatar Mar 24 '20 15:03 matthims