morefigs / py-ic-imaging-control

Python wrapper for the IC Imaging Control SDK from The Imaging Source (TIS)
MIT License
33 stars 22 forks source link

Save_Image Error #25

Open dpalo325 opened 6 years ago

dpalo325 commented 6 years ago

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

morefigs commented 6 years ago

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.

dpalo325 commented 6 years ago

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.

nikhil4595 commented 5 years ago

@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 ?

morefigs commented 5 years ago

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.

matthims commented 4 years ago

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.