Code Monkey home page Code Monkey logo

Comments (10)

Joonch avatar Joonch commented on June 12, 2024 1

I've just had a major breakthrough! To convert just one image, take an image, resize to a width of 909 px in gimp, export, change file extension to .pgm, select ASCII, edit the .pgm file in Notepad++ to get rid of the comment on line 2, save, duplicate the file so you have 2 copies (one named image1.pgm and the other image2.pgm), enter the cmd, cd into the directory of the .exe (.pgm images has to be in the same directory too!), type "apt-encode.exe image1.pgm image2.pgm > encode.raw", find the raw file in the directory, open audacity, "import raw data", set the sample rate to 11025, save as .wav or .mp3. Eureka!

from apt-encoder.

gkbrk avatar gkbrk commented on June 12, 2024

Hi! Although I haven't tested it on Windows yet, I'm pretty sure it should work if you are using Cygwin to compile.

For Raspberry Pi, can you try pulling the latest changes and compiling again?

from apt-encoder.

gkbrk avatar gkbrk commented on June 12, 2024

Hey @Marleu, did you manage to try the fix?

from apt-encoder.

Joonch avatar Joonch commented on June 12, 2024

Hi! I'm trying to use the make command on Ubuntu to compile the program, but I keep getting "ignored fread" and "Ignored fscan" errors. I'm kind of a newbie at using open source programs/building from source and I'm probably not explaining it right so I'll paste the error below. Thanks!
g++ -Wall -Wextra -Werror -pedantic -std=c++17 -Os -flto -s -o apt-encode apt-encode.cpp
apt-encode.cpp: In constructor ‘Image::Image(const char*)’:
apt-encode.cpp:69:17: error: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Werror=unused-result]
69 | (void) fread(buf, 1, 2, f);
| ~~~~~^~~~~~~~~~~~~~
apt-encode.cpp:72:9: error: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’, declared with attribute warn_unused_result [-Werror=unused-result]
72 | fscanf(f, "%zu %zu %zu", &width, &m_height, &maxValue);
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
apt-encode.cpp:77:11: error: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’, declared with attribute warn_unused_result [-Werror=unused-result]
77 | fscanf(f, "%hhu", &m_pixels[i]);
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make: *** [Makefile:5: apt-encode] Error 1

from apt-encoder.

gkbrk avatar gkbrk commented on June 12, 2024

@BirbGoSqueek19 this was caused by Makefile being too strict about warnings. You should be able to build it now, or at least get a different error.

from apt-encoder.

Joonch avatar Joonch commented on June 12, 2024

Thanks, I did actually figure out last night that I needed to remove the -Werror thing in the Makefile to stop make from interpreting warnings as errors. The makefile compiles the program, but the file that it outputs is not an executable nor a binary. The file that it outputs is a "shared library". Specifically, Ubuntu calls it "shared library (application/x-sharedlib)" and
I can't open it. When I try and switch my OS to use Cygwin on Windows 10, it does actually compile as an .exe but when I use apt-encode.exe image1.pgm image2.pgm in cmd (I do have the images in .pgm ASCII format and I removed the comment line that GIMP adds, I also duplicated the image that I wanted to encode bc the instructions say "Just pass the same file to the program twice.") it just blasts out random symbols like the matrix. Looks kinda cool, but not what I need. Lastly, using " ./apt-encode ~/image1.pgm ~/image2.pgm | aplay -r 8320" doesn't work because aplay isn't a command in Windows and using " ./apt-encode ~/image1.pgm ~/image2.pgm > encode.raw
sox -t raw -b 8 -e unsigned -c 1 -r 8320 encode.raw -r 11025 ~/apt.wav" just creates a .raw image file (?) in the program folder that has no data when I inspect it. Success is so close I can taste it.

from apt-encoder.

Joonch avatar Joonch commented on June 12, 2024

Update: WXtoIMG displays my image, but its so heavily interlaced (is that the right word?) and I can't seem to fix it. Here's an example with the "E" meme. Also, I'm only able to get black and white images out. Is this the only output of the program or is there a way to do color?
image

from apt-encoder.

gkbrk avatar gkbrk commented on June 12, 2024

Might be related to the sample rate you picked. If the configuration in your .cpp file is BAUD = 4160 and OVERSAMPLE = 3, the sample rate you need to import to audacity will be 4160 * 3 = 12480.

from apt-encoder.

Joonch avatar Joonch commented on June 12, 2024

I have successfully been able to ditch audacity by using the sox command as you described in the instructions, but with one minor change. For wxtoimg (or at least for me), the -r values need to both be changed to 12480, assuming you haven't touched the BAUD and OVERSAMPLE under //Constants and Config.
Original sox command: "sox.exe -t raw -b 8 -e unsigned -c 1 -r 8320 encode.raw -r 11025 apt.wav"
Sox command that produces good image in wxtoimg: sox.exe -t raw -b 8 -e unsigned -c 1 -r 12480 encode.raw -r 12480 apt.wav
Note for wxtoimg users: The best image comes from doing "Manual Record" and using VBaudio Cable to pipe the wav file from a music player to wxtoimg. The "Import audio file" option seems to stretch the image. Thanks for all the help!
01091937

from apt-encoder.

gkbrk avatar gkbrk commented on June 12, 2024

I think the original build issue is long gone now. I'm closing this issue. Thanks @Joonch for the instructions that might help people on Windows.

from apt-encoder.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.