|
MyroC Project
Package to control Scribbler 2 robots via Bluetooth
|
Implementation file for saving/loading jpeg images to/from a file. More...
#include "MyroC.h"#include "MyroC-utilities.h"#include <stdio.h>#include <stdlib.h>#include <ctype.h>#include <string.h>#include <fcntl.h>#include <unistd.h>#include <jpeglib.h>#include <setjmp.h>
Data Structures | |
| struct | my_error_mgr |
Typedefs | |
| typedef struct my_error_mgr * | my_error_ptr |
Functions | |
| void | my_error_exit (j_common_ptr cinfo) |
| void | rSavePicture (Picture *pic, char *filename) |
| Save a Picture to a .jpeg. More... | |
| Picture | rLoadPicture (char *filename) |
| Load a picture from a .jpeg file. More... | |
Implementation file for saving/loading jpeg images to/from a file.
Revision History
Version 1.0 based on a C++ package by April O'Neill, David Cowden, Dilan Ustek, Erik Opavsky, and Henry M. Walker
Developers of the C package for Linux: Creators Version 2.0 (C functions for utilities,general,sensors,movement): Spencer Liberto Dilan Ustek Jordan Yuan Henry M. Walker Contributors Version 2.2-2.3: (C functions for image processing) Anita DeWitt Jason Liu Nick Knoebber Vasilisa Bashlovkina Revision for Version 2.4: (image row/column made to match matrix notation) Henry M. Walker
Revisions for Version 3.0 Henry M. Walker
C ported to Macintosh Linux/Mac differences required for connections — otherwise same code OpenGL used to display images, replacing ImageMagick same [new] code used for both Linux and Macintosh 1 process for robot control 1 process needed for each titled window (not each image, as in 2.2-2.4) Blocking options (negative duration parameter) utilize separate thread timer MyroC implementation files organized by user function as follows:
Revisions for Version 3.1 Henry M. Walker
Picture struct and image functions revised to allow 192 by 256 images from origial Fluke camera 266 x 427 low-resolution images from Fluke 2 (high-resolution (800 x 1280) too large for more than 2-4 variables on run-time stack) storage , retrieval, and display of any images up to 266 x 427
This program and all MyroC software is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License. Details available at http://creativecommons.org/licenses/by-nc-sa/3.0/us/
Revisions for Version 3.2 Henry M. Walker
Practical range of rBeep duration identified as <= 3.0014 seconds Image display and processing resolves several matters and adds functionality function rDisplayPicture completely rewritten over time OpenGL rountines had encountered troubles on Linux, specifically glutHideWindow() hid images, but could not be restored, with difficulties depending on the graphics card on Mac, High Sierra generated compile warnings and restricted threads that could display images function rDisplayImageProcessingErrors added function rWaitTimedImageDisplay updated substantially
Revisions for Version 3.3 Henry M. Walker
MyroC ported to Windows 10, in addition to Linux and Mac OS X Additional refinements text parameter for rGetLightTxt expanded to "Middle" as well as "Center"
This program and all MyroC software is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License. Details may be found at http://creativecommons.org/licenses/by-nc-sa/3.0/us/
implementation overview *************************
indicates functions implemented in this file
0. LOW-LEVEL UTILITY (defined in MyroC-utilities.h implemented in MyroC-utilities.c) rSend rReceive rSetOpeningExchange rSetBluetoothEcho rSetEchoMode rCheckHardwareVersionSetCameraSize
Note:
MyroC-connect requires special
knowledge of a Mac or Linux
environment, yielding two versions:
MyroC-connect-mac.c
MyroC-connect-linux.c
| Picture rLoadPicture | ( | char * | filename | ) |
Load a picture from a .jpeg file.
| filename | the name of the file |
| void rSavePicture | ( | Picture * | pic, |
| char * | filename | ||
| ) |
Save a Picture to a .jpeg.
This section contains functions for taking and manipulating images All images are constrained with height <= 266 and width <= 427
images from robot cameras have varying sizes, depending on the Fluke images for the original Fluke are 192 (height) by 256 (width) low-resolution images for the Fluke 2 are 266 by 427 high-resolution images for the fluke 2 are 800 by 1280 (not supported)
Bluetooth communication constrains the time required for the Fluke to take a picture Typical times: original fluke: 2- 4 seconds Fluke 2 (low res): 4- 6 seconds Fluke 2 (high res): 25-30 seconds
BASED ON TIMINGS AND MEMORY CONSIDERATIONS, Myro C ALLOWS ONLY LOW RESOLUTION IMAGES
the Picture struct allows direct access to Pixel data Pictures can be saved and loaded as .jpeg files
| pic | pointer to an RGB picture struct from Scribbler 2 camera |
| filename | the name of the file |
this code is a slightly modified version of write_JPEG_file(char *, int) from example.c from the libjpeg.v8d library directory.
1.8.13