csi-dcsc / Pycrafter6500

A python controller for Texas Instruments DLPLCR6500EVM evaluation module for DLP technology. The controller can fully control the "pattern on the fly" mode with a user defined sequence of binary images. Requires pyusb and numpy. PIL or pillow is recommended for testing.
GNU General Public License v3.0
38 stars 17 forks source link

Float and Int Errors for Multiple Methods #1

Closed devWork1 closed 2 years ago

devWork1 commented 3 years ago

Hello,

Thank you for writing up this code. I have ran into multiple float errors for methods including defsequence.

The errors typically are associated when performing functions such as: "for i in range((num-1)/24+1)"

...where num is the len(arr) and array is a list of 1080 x 1920 arrays (PIL bit images converted to arrays).

Currently using Python 3.7.3.

Think you could help me out?

Thank you,

-dev

e841018 commented 3 years ago

The code is written for Python 2, so you will need to do some modifications.

devWork1 commented 3 years ago

Thank you very much. I figured as far as the python2 needs to be converted over to python3.

With regards to the defsequence method, is the images argument expected to be a list of numpy arrays? And is that list expected to be a list of 'some number' long?

It appears that unless 'num' = 26, you would never get something that was inherently an integer for: "for i in range((num-1)/24+1):" Even, then as written, it would have to be rewritten as... "for i in range(int((num-1)/24+1)):" ...to avoid the Float error.

Am I missing something entirely? I'd love to use your code cause it does exactly what I'm looking for... if I was clever enough to get it to work.

Thank you again,

-dev

e841018 commented 3 years ago

To clarify, I am not the author of this repository, but just a user that used some segments of the code. I can tell you my experience, but I'm not sure if it works in your case.

In Python 3, just use the floor division operator, //.

(num-1)//24+1

The images argument is expected to be a list of numpy arrays, of length >=1.

Seems like you are not familiar with Python 3, and I would recommend you to follow some tutorials so that you get to know some features of the language.

I did a lot of modifications and no longer follow the function signatures of Pycrafter6500, and there's still some unsolved issues, so I'm not releasing my code recently. What I've learned is that sometimes it is the hardware that causes the problem, so several reboots of the EVM might magically make things work.

viswanath-dreams commented 3 years ago

There are major issues with floating point numbers in the loops in this code. All of them need to be rounded to the nearest integer for the code to work.

Also, as another user mentioned, the hardware also has some issue with handling these codes. It often goes into a loop state when it is accessed with the python code and freezes. It requires a complete reboot to fix the problem.. So i strongly suggest you test the code by commenting out the hardware sections before you upload to the machine..

In case you are familiar with LabVIEW or comfortable with Excel VB, DLiinovations shared a Labview and excel executable to control the EVM. But this will work only if you use the firmware uploaded by Dliiinovations.

If i remember correctly, i assumed this code was written for images data set of size (1920,1080,24) (per frame), and they had multiple sets of 24 images to process. I had to rewrite this for bitmap images.

viswanath-dreams commented 3 years ago

Well scratch that previous comment out, i dont fully remember why the 24 was included.. maybe to access the RGB channels.. Anyways - i think i have a working version of this code for python 3, but never ended up using it. I'll share it once i find it..

devWork1 commented 3 years ago

Thanks for all of the feedback.

@e841018 I'll definitely give the floor operator a try and and comment out the hardware portions as well.

@viswanath-dreams If you happen to find that python 3 code, that would be phenomenal. Thanks for sharing the info on some alternatives. I'm trying to build this python controller into a larger fully integrated python system, as to minimize the number of interfaces we'll need.

ppozzi commented 3 years ago

Hello guys,

i'm the actual developer of the code (sorry for all the headaches). As you said, the main problem with it is that it's made for Python 2, and i cannot upgrade it to Python 3 myself, as i do not have a dmd anymore to test it (changed job, still doing optics & microscopy, but more into phase-only SLMs now). If you happen to have a working Python 3 version feel free to either:

1- Send it to me, i'll update the code, add acknowledgements in the readme and pay you a beer if we meet at a conference once the pademic is over. 2 - Send a pull request to change the code yourself to figure amongst the authors. 3 - Make your own public fork to take full credit of the change (and full responsibility to assist users with eventual problems). I'll add a link to it in the readme of this one.

Of course, if you choose option 2 or 3, the beer offer still stands.

Cheers, thanks for using my code!

zhaoguangyuan123 commented 3 years ago

I have emailed the owner of this repo of the workable python3 version, which I test on the 6500 this afternoon. Hope this can help others. Also, thank the Paolo for make this repo open source!

devWork1 commented 3 years ago

Hey!

That’s fantastic! I think I have something that works for python3. I can load up images, but I am not sure what the original intent of the code was functionally, cause it appears to be combining images.

I look forward to seeing what y’all come up with cause I’m stumped.

-Kyle

From: Guangyuan Zhao notifications@github.com Sent: Tuesday, November 24, 2020 9:43 PM To: csi-dcsc/Pycrafter6500 Pycrafter6500@noreply.github.com Cc: Devlugt, Kyle Thomas devlugt1@llnl.gov; Author author@noreply.github.com Subject: Re: [csi-dcsc/Pycrafter6500] Float and Int Errors for Multiple Methods (#1)

I have emailed the owner of this repo of the workable python3 version, which I test on the 6500 this afternoon. Hope this can help others. Also, thank the Paolo for make this repo open source!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/csi-dcsc/Pycrafter6500/issues/1#issuecomment-733479783, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARWWODX6AX3QZFJAQRLXEE3SRSKP3ANCNFSM4TRMREIQ.

e841018 commented 3 years ago

I think the purpose to compress 24 binary images into a 24-bit image is to maximize the throughput. Refer to the figures on page 43 of https://www.ti.com/lit/ug/dlpu018e/dlpu018e.pdf I guess there's some hardware that handles 24-bit images and it's shared with binary images. That's why the batch size is fixed to 24.

devWork1 commented 3 years ago

Thanks to all of your feedback, I am starting to put two-and-two together. Looking for a quick way to sequence bitmaps without merging them. So looks like I’m in for some mod work. If you have something, I’m all ears.

From: T.H.YU notifications@github.com Sent: Tuesday, November 24, 2020 11:54 PM To: csi-dcsc/Pycrafter6500 Pycrafter6500@noreply.github.com Cc: Devlugt, Kyle Thomas devlugt1@llnl.gov; Author author@noreply.github.com Subject: Re: [csi-dcsc/Pycrafter6500] Float and Int Errors for Multiple Methods (#1)

I think the purpose to compress 24 binary images into a 24-bit image is to maximize the throughput. Refer to the figures on page 43 of https://www.ti.com/lit/ug/dlpu018e/dlpu018e.pdf I guess there's some hardware that handles 24-bit images and it's shared with binary images. That's why the batch size is fixed to 24.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/csi-dcsc/Pycrafter6500/issues/1#issuecomment-733531991, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARWWODSOBYCA54HQ3GBSVR3SRSZ3HANCNFSM4TRMREIQ.

ppozzi commented 3 years ago

Hello all,

i confirm i received the code from Zhao (many, many thanks). Today is a pretty busy day, but i'll try to modify the library in the evening. At first i'll probably just add Zhao's file as a "pycrafter6500-py3.py", and instructions in the readme on which to use based on your Python version. Later i'll try to integrate them in a single file that works on both python 2 and python 3, i may need some testing from some of you to make sure it works, if it's ok.

As for the images upload, the DMD was engineered as a device to show 24-bit RGB images, and binary patterns seems to have been an afterthought from Texas instruments engineers. This means that even if you have a single binary pattern to upload, you need to create a 24 bit image, where your binary pattern is encoded as the first bit of the red channel. This unfortunately slows down the whole process a lot, but as far as i know there is no real way around it.

Thanks again for all the support, i'll try to have Zhao's code up by this (eouropean) evening. Cheers!

ppozzi commented 3 years ago

Ok, i applied Zhao's modifications to the code, from the look of it, it should work both with Python 2 and with Python 3. If any of you guys can try to clone the code and test it on an actual device, i will close this issue. Thanks all for your help.