mitxela.com forum
Welcome. Please log in or register.

Thermal Polaroid
bpye Posted: 7 May 2018, 02:31 PM
Avatar


Member
Posts: 1
Joined: 7-May 18
Hey,

Saw the thermal Polaroid project, very cool.

I did some digging and it looks like you can change the baud rate on a lot of the printers which might have made the TTL interface an option, the tool on https://www.dkia.at/en/node/129 should work with several and others seem to have an ESC/POS command for it.

I also wonder if it'd be possible to actually have the webcam behind the autofocus mechanism, though I suspect any "focusing" done wouldn't really be reflected by the printed image.

I might have to have a go at making one of these myself.

-------------
[top]
mit Posted: 7 May 2018, 08:24 PM
Avatar
yeah whatever

Admin
Posts: 541
Joined: 4-May 16
I'm pretty sure it wasn't possible to change the baud rate on my particular printer, although I didn't try that tool, I did try a few of the ESC/POS commands for it.

The webcam is behind the autofocus, at least when the focus racks the plastic cylinder around the lens rotates still. I don't think it would have been possible to link this to the webcam's focus mechanism, the threaded parts are at different pitches. The webcam has such a tiny sensor anyway, the depth of field is big enough that focusing the image isn't important really.

-------------
[top]
BitcherofBlaviken Posted: 9 May 2018, 02:25 AM
Avatar


Member
Posts: 1
Joined: 9-May 18
I'm trying to go make a thermal polaroid of my own by folowwing your guide.

What exactly was the script you use to generate bitmap images for the printer?

-------------
[top]
mit Posted: 9 May 2018, 07:00 PM
Avatar
yeah whatever

Admin
Posts: 541
Joined: 4-May 16
The two scripts I used were the C++ snippet that turns a YUYV buffer into a JPEG, and the python script that resizes and dithers the image, and appends the right header to the data. The first script is probably not needed if your camera supports other output formats.

Both scripts are linked to on the project writeup.

There is also a "full" python ESC/POS library but it has a lot of dependencies and features I didn't need.

-------------
[top]
sphunts01 Posted: 25 Oct 2023, 06:18 AM
Avatar


Member
Posts: 3
Joined: 25-October 23
I've been trying to get that c++ snippet to compile but its giving me errors and I don't know enough to figure out why. I've checked, my camera also only supports YUYV. Any chance you could upload the compiled file? Its been so long you probably don't have it ):


I'm getting a compile error on line 32 about cannot convert 'uint64_t*' to 'long unsigned int*' and I'm so lost.

Any help appreciated, I love this project.

-------------
[top]
mit Posted: 28 Oct 2023, 09:25 AM
Avatar
yeah whatever

Admin
Posts: 541
Joined: 4-May 16
QUOTE
I've been trying to get that c++ snippet to compile but its giving me errors and I don't know enough to figure out why. I've checked, my camera also only supports YUYV. Any chance you could upload the compiled file? Its been so long you probably don't have it ):

It's been too long for me to have the files I'm afraid, but if you post the command you used to compile it and the full error I can try and spot any problems.

Also are you compiling it to run natively, or cross-compiling it to run on a raspberry pi? Or trying to compile it on the pi?

-------------
[top]
sphunts01 Posted: 6 Nov 2023, 05:54 PM
Avatar


Member
Posts: 3
Joined: 25-October 23
I'm trying to compile this code https://gist.github.com/royshil/fa98604b01787172b270

I am trying to compile it on the pi itself. Its a rpi zero w v1.1

The command I'm using is:
g++ CompressYUYV2JPEG.cpp -o yuyvArm -std=c++11 -ljpeg


And the error I get is:

CompressYUYV2JPEG.cpp:32:39: error: cannot convert ‘uint64_t*’ {aka ‘long long unsigned int*’} to ‘long unsigned int*’
32 | jpeg_mem_dest(&cinfo, &outbuffer, &outlen);
| ^~~~~~~
| |
| uint64_t* {aka long long unsigned int*}
In file included from CompressYUYV2JPEG.cpp:7:
/usr/include/jpeglib.h:922:43: note: initializing argument 3 of ‘void jpeg_mem_dest(j_compress_ptr, unsigned char**, long unsigned int*)’
922 | unsigned long *outsize);
| ~~~~~~~~~~~~~~~^~~~~~~


-------------
[top]
mit Posted: 7 Nov 2023, 11:22 PM
Avatar
yeah whatever

Admin
Posts: 541
Joined: 4-May 16
I don't have a pi to hand to try compiling it myself, but if you're not doing buildroot, why not just capture the image using ffmpeg or avconv, which can convert the format for you? The command is further up on the project page:

/usr/bin/avconv -f video4linux2 -pix_fmt rgb24 -video_size 640x480 -i /dev/video0 -vframes 1 /home/pi/blaa.png


-------------
[top]
sphunts01 Posted: 8 Nov 2023, 04:27 PM
Avatar


Member
Posts: 3
Joined: 25-October 23
I appreciate your feedback immensely.

I wasn't using that because it takes quite a while to start up ffmpeg, so from the button press to take a picture, to when the picture is actually taken is a good few seconds which makes it weird as a camera.

Right now I made the yuyv to jpeg in python, so it can take the picture almost immediately, and then converts it. It just takes longer overall than ffmpeg, but is more intuitive to use.

Thats why I was hoping to be able to do it in c like you had for speed.

Last edit by sphunts01 at 8 Nov 2023, 04:31 PM

-------------
[top]
mit Posted: 10 Nov 2023, 02:11 AM
Avatar
yeah whatever

Admin
Posts: 541
Joined: 4-May 16
The conversion from yuyv to rgb should be very quick, my feeling is that the slow part would be the jpeg encoding. You could output to a bitmap in a tempfs and see if that helps.

Or it may be that the particular python code is doing something very inefficient. If you use numpy it should be almost as fast as compiled code. I guess you've probably already googled it but there seem to be a few examples out there.

Anyway I booted up my old laptop and turns out it was surprisingly easy to find the file you're asking for. No idea if it will work on your pi, my one was an original pi zero. Here: http://mitxela.com/~yuyvArm

-------------
[top]

Sign in to post a reply.