How to stream JPG Images?

Hello,
I am looking to stream jpg images from a program my friend made. The format he sends is 4 bytes header then the jpg image, and I would prefer not to change this if I don't have to. I have created some code to do this, but I am unable to get to the camera currently to test it. Does this look like it will work (or am I on the wrong track completely?):
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.Socket;
import com.sun.image.codec.jpeg.ImageFormatException;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageDecoder;
public class CameraObservable
     private byte[] header = new byte[4];
     private boolean running = true;
     public CameraObservable(String ipAddress, int port)
          try
               Socket inputSocket = new Socket(ipAddress, port);          
               JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(inputSocket.getInputStream());
               while(running==true)
                    inputSocket.getInputStream().read(header);
                    BufferedImage myBufferedImage = decoder.decodeAsBufferedImage();
          } catch (ImageFormatException e)
               e.printStackTrace();
          } catch (IOException e)
               e.printStackTrace();
     public static void main(String[] args)
          new CameraObservable("192.168.1.3",5553);
}Thanks for your input,
Eric

You can't assume the read fills the buffer. See the Javadoc. See also DataInputStream.readFully().
You probably can't also assume that constructing the decoder doesn't read anything from the stream. I would construct a new one per image, after reading the header. I would also check what's in the header rather than just throwing it away.

Similar Messages

  • Can any one tell me how to stream the images in flash.

    Hello Friends,
    i have created a dynamic page flip book with xml, i want to
    zoom the images in swf loaded, with streaming, so that user can
    preview the image while a good quality image is loading. I wanna
    know that how to load a part of large image or swf.
    Image effect like :-
    http://www.zoomify.com/
    Can any one tell me how to stream the images in flash.

    On Thu, 17 Apr 2008 05:53:27 +0000 (UTC), "FlashDavil"
    <[email protected]> wrote:
    >I wanna know that how to load a
    >part of large image or swf.
    You show a preview and use loadMovie() to load a big file.
    You can
    create a preloader (progress bar) showing how much part is
    loaded,
    while user sees the small image. When you achieve 100% tou
    show that
    big image. What's more?
    > Can any one tell me how to stream the images in flash.
    What are you talking about is not a "streaming", but
    "progressive
    download". Images "streaming" is impossible.

  • How to convert JPG image to BMP ? (Printing jpg images in smartforms from content server)

    Hi,
    We have employee photos(JPG Format) stored in Content server. And now we want to print the photos in smartforms. For this I had written the below code to read the photo from content server in binary format as below.
    REPORT ZTEST1.
    PARAMETERS P_PERNR TYPE PERNR_D.
    DATA: PS_CONNECT_INFO TYPE TOAV0,
          IT_BINARY TYPE TABLE OF SDOKCNTBIN.
    CALL FUNCTION 'HR_IMAGE_EXISTS'
      EXPORTING
        P_PERNR                     = P_PERNR
    *   P_TCLAS                     = 'A'
    *   P_BEGDA                     = '18000101'
    *   P_ENDDA                     = '99991231'
    IMPORTING
    *   P_EXISTS                    =
       P_CONNECT_INFO              = PS_CONNECT_INFO
    * EXCEPTIONS
    * ERROR_CONNECTIONTABLE       = 1
    *   OTHERS                      = 2
    IF SY-SUBRC <> 0.
    * Implement suitable error handling here
    ENDIF.
    IF PS_CONNECT_INFO IS NOT INITIAL.
      CALL FUNCTION 'SCMS_DOC_READ'
        EXPORTING
       STOR_CAT                    = SPACE
       CREP_ID                     = PS_CONNECT_INFO-ARCHIV_ID
          DOC_ID                      = PS_CONNECT_INFO-ARC_DOC_ID
    *   PHIO_ID                     =
    *   SIGNATURE                   = 'X'
    *   SECURITY                    = ' '
    *   NO_CACHE                    = ' '
    *   RAW_MODE                    = ' '
    * IMPORTING
    *   FROM_CACHE                  =
    *   CREA_TIME                   =
    *   CREA_DATE                   =
    *   CHNG_TIME                   =
    *   CHNG_DATE                   =
    *   STATUS                      =
    *   DOC_PROT                    =
    TABLES
    *   ACCESS_INFO                 =
    *   CONTENT_TXT                 =
       CONTENT_BIN                 = IT_BINARY
    * EXCEPTIONS
    * BAD_STORAGE_TYPE            = 1
    *   BAD_REQUEST                 = 2
    *   UNAUTHORIZED                = 3
    * COMP_NOT_FOUND              = 4
    *   NOT_FOUND                   = 5
    *   FORBIDDEN                   = 6
    *   CONFLICT                    = 7
    * INTERNAL_SERVER_ERROR       = 8
    *   ERROR_HTTP                  = 9
    * ERROR_SIGNATURE             = 10
    *   ERROR_CONFIG                = 11
    *   ERROR_FORMAT                = 12
    * ERROR_PARAMETER             = 13
    *   ERROR                       = 14
    *   OTHERS                      = 15
      IF SY-SUBRC <> 0.
    * Implement suitable error handling here
      ENDIF.
    ENDIF
    Now the issue is I want to convert that binary data to bitmap image and upload the same in to SE78. So that I can use that BMP image from SE78 in my smartforms.
    I had used the class CL_IGS_IMAGE_CONVERTER to covert the image into bmp but it is giving error that error in IMAGE DATA CORRUPT & Error Code 3. The conversion code used is as below.
    ******* CONVERT THE JPG IMAGE INTO BMP PHOTO. **********
      DATA: L_IGS_IMGCONV TYPE REF TO CL_IGS_IMAGE_CONVERTER,
    L_IMG_BLOB    TYPE W3MIMETABTYPE,
    L_IMG_SIZE    TYPE W3PARAM-CONT_LEN,
    L_IMG_TYPE    TYPE W3PARAM-CONT_TYPE,
             L_IMG_SUBTYPE TYPE W3PARAM-CONT_TYPE,
    L_IMG_URL     TYPE W3URL,
    L_ERR_CODE    TYPE I,
    L_ERR_TEXT    TYPE STRING,
             P_DEST TYPE CHAR32 VALUE 'IGS_RFC_DEST'.
      DATA: G_IMG_BLOB     TYPE W3MIMETABTYPE,
          G_IMG_TYPE     TYPE W3PARAM-CONT_TYPE,
          G_IMG_SIZE     TYPE W3PARAM-CONT_LEN.
      IF NOT IT_BINARY[] IS INITIAL.
        G_IMG_BLOB[] = IT_BINARY.
        CREATE OBJECT L_IGS_IMGCONV
          EXPORTING
            DESTINATION = P_DEST.
        CALL METHOD L_IGS_IMGCONV->SET_IMAGE
          EXPORTING
            BLOB      = G_IMG_BLOB
            BLOB_SIZE = G_IMG_SIZE.
        CASE PS_CONNECT_INFO-RESERVE.
          WHEN 'TIF'.
            G_IMG_TYPE = 'image/tiff'.
          WHEN 'JPG'.
            G_IMG_TYPE = 'image/jpeg'.
          WHEN 'PNG'.
            G_IMG_TYPE = 'image/png'.
          WHEN 'GIF'.
            G_IMG_TYPE = 'image/gif'.
          WHEN 'BMP'.
            G_IMG_TYPE = 'image/x-ms-bmp'.
          WHEN OTHERS.
            EXIT.
        ENDCASE.
    L_IGS_IMGCONV->INPUT  = G_IMG_TYPE.
        L_IGS_IMGCONV->OUTPUT = 'image/x-ms-bmp'.
    *    PERFORM GET_SIZE USING PICTURE_CONTAINER
    * L_IGS_IMGCONV->WIDTH
    * L_IGS_IMGCONV->HEIGHT.
        CALL METHOD L_IGS_IMGCONV->EXECUTE
          EXCEPTIONS
            OTHERS = 1.
        IF SY-SUBRC IS INITIAL.
          CALL METHOD L_IGS_IMGCONV->GET_IMAGE
            IMPORTING
              BLOB      = L_IMG_BLOB
              BLOB_SIZE = L_IMG_SIZE
              BLOB_TYPE = L_IMG_TYPE.
          SPLIT L_IMG_TYPE AT '/' INTO L_IMG_TYPE L_IMG_SUBTYPE.
        ELSE.
          CALL METHOD L_IGS_IMGCONV->GET_ERROR
            IMPORTING
              NUMBER  = L_ERR_CODE
              MESSAGE = L_ERR_TEXT.
          BREAK-POINT.
        ENDIF.
      ENDIF.
    ENDIF.
    So could you please some one help me how to convert JPEG Photo to BMP programatically.
    Regards,
    Mayur.

    johnandersonpalmdesert wrote:
    My printer is requesting a vector file.
    Jpeg File format does not support vectors.  Photoshop has limited vector support and tools.  Photoshop can not save vector file formats like SVG.  What File type does your printer want?
    Adobe Illustrator is Adobe vector application.

  • How to read  jpg image from a specified path

    Hi
    I am having an image in jpg ext, so i am using File nf = new File(path);to read the image, now i have to place that jpg image in an byte/String array so from that i will save that in to the Oracle DB with BLOB data type, plz answer to this asap with code......
    the following code is not useful i think so...
         String st = "C:\Documents and Settings\Sasi\Desktop\sasi.jpg"    
          File infile = new File(st);
         BufferedImage im = ImageIO.read(infile);
         String[] reader_names = ImageIO.getReaderFormatNames();plz reply to this asap,
    regards
    sasi

    Sasi9 wrote:
    String st = "C:\Documents and Settings\Sasi\Desktop\sasi.jpg"    
    File infile = new File(st);
    //BufferedImage im = ImageIO.read(infile);
    //String[] reader_names = ImageIO.getReaderFormatNames();
    byte[] buffer = new byte[infile.length()];Now use a RandomAccessFile to read the file into your byte array. [readFully(buffer);|http://java.sun.com/j2se/1.4.2/docs/api/java/io/RandomAccessFile.html]

  • How to streaming data/image from labview to a third party software

    Hi, i am working on a research project and stuck on the following problem: I have two cameras and one IMU Sensor unit, all conected to my PC. I save the camera images as avi format and the IMU sensor as TDMS format. I have also another software running on the same PC which i developed using VisualStudio2013.  On this software i alredy implemented a very complex filter to fuse images and IMU.  Now my quesion: would be it possibel to stream the .avi and .tdms from LabView to my software so I can test in real time how my filter is performing? If yes please let me know what LabView function do i have to use. thanks

    Thanks, the hardware are my PC, 2 usb cameras and one usb-IMU sensor. The PC runs w7 with LabView2014. I can read the camera and IMU to my Laview without any problem and save the data on my hard desk. I am also developing another software on VS-C++ for image processing and data fusion. I would like to know what is the best (and fastest) possibility to stream this data (Images and IMU) in real time from LabView to my own software?
    I read a lot in NI-website on how to communicate LabView with a third party software. They are summarized in this link:
    https://decibel.ni.com/content/docs/DOC-9131
    It looks for me that the ‘shard memory’ principle (or File Mapping) is the most convenient method. In VC++ under windows I can easily handle shared memory by calling FileMapping windows functions. Now the question is how can I do that in LabView? I am relatively new in LabView and do not know if it is possible to use shared memory in LabView. For example: is it possible in LabView to buffer both video streams and IMU-data (live) in a shared memory in computer RAM using the windows FileMaping functions (may be using .dll). Then I can access the RAM form my own software and read the stream. Please see the attachment for more description.
    Attachments:
    Unbenannt.PNG ‏139 KB

  • Is there any way how to generate JPG image from DNG easily?

    I use PS, FW and Bridge.
    I have often a problem to show images for preview from DNG files.
    Please can you explain me, how to do it as a batch easily? Generate preview images from a whole folder?
    Do you generate JPG in original size or do you archive only DNG?
    Thank you

    Little confused here.  Are you saying you do not get a thumbnail for a DNG and therefore can not view as a preview?
    If you want to batch convert a DNG to a jpeg you can use tools/photoshop/image processor.

  • How to print JPG image retrieved from BLOB in a table using Forms10g

    I create a database schema and a Form to maintain JPG to the table PHOTOS.
    I would like to add a button to PRINT just the PHOTO_IMAGE to its maximum size from a Form. How can I do that? Is thaere any built-in Forms functions to do that? If the client is using Windows XP, can I use CLIENT_HOST() to call a program to print the JPG file directly?
    Any suggestion is welcome.
    -- myphotos.sql
    drop user myphoto cascade;
    create user myphoto identified by myphoto;
    grant connect, resource, ctxapp to myphoto;
    connect myphoto/myphoto@orcl;
    PROMPT Creating Table USERS
    CREATE TABLE USERS
    (USER_ID VARCHAR2(8) NOT NULL,
    USER_LASTNAME VARCHAR2(15) NOT NULL,
    USER_FIRSTNAME VARCHAR2(30) NOT NULL,
    USER_PASSWORD VARCHAR2(20) NOT NULL,
    CONSTRAINT PK_USERS PRIMARY KEY (USER_ID)
    PROMPT Creating Table PHOTOS
    CREATE TABLE PHOTOS
    (PHOTO_ID VARCHAR2(15) NOT NULL,
    PHOTO_IMAGE BLOB,
    TEXT_DESCRIPTION CLOB,
    FILENAME VARCHAR2(50),
    FILE_SIZE NUMBER NOT NULL,
    USER_ID VARCHAR2(8) NOT NULL,
    ACCESS_RIGHT VARCHAR2(7) NOT NULL,
    CONSTRAINT CK_ACCESS_RIGHT CHECK (ACCESS_RIGHT IN ('PRIVATE', 'PUBLIC')),
    CONSTRAINT PK_PHOTOS PRIMARY KEY (PHOTO_ID),
    CONSTRAINT FK_USER_ID FOREIGN KEY (USER_ID) REFERENCES USERS (USER_ID)
    create index idx_photos_text_desc on
    PHOTOS(TEXT_DESCRIPTION) indextype is ctxsys.context;
    INSERT INTO USERS VALUES ('G345566A','WONG', 'TAI SIN','WONGTAISIN');
    INSERT INTO PHOTOS VALUES
    ('P00000000000001', empty_blob(), empty_clob(),
    'SCGP1.JPG',100,'G345566A','PUBLIC');
    INSERT INTO PHOTOS VALUES
    ('P00000000000002', empty_blob(), 'Cold Play with me at the concert in Melbourne 2005',
    'COLDPLAY1.JPG',200,'G345566A','PUBLIC');
    INSERT INTO PHOTOS VALUES
    ('P00000000000003', empty_blob(), 'My parents in Melbourne 2001',
    'COLDPLAY1.JPG',200,'G345566A','PRIVATE');
    COMMIT;
    EXEC CTX_DDL.SYNC_INDEX('idx_photos_text_desc');
    SELECT USER_ID,PHOTO_ID ,TEXT_DESCRIPTION
    FROM PHOTOS
    ORDER BY USER_ID;
    SELECT score(1),PHOTO_ID ,TEXT_DESCRIPTION
    FROM PHOTOS
    WHERE CONTAINS(TEXT_DESCRIPTION,'parents',1)> 0
    ORDER BY USER_ID,score(1) DESC;
    SELECT USER_ID,score(1),PHOTO_ID ,TEXT_DESCRIPTION
    FROM PHOTOS
    WHERE CONTAINS(TEXT_DESCRIPTION,'cold play',1)> 0
    ORDER BY USER_ID,score(1) DESC;
    SELECT USER_ID,score(1),score(2), PHOTO_ID ,TEXT_DESCRIPTION
    FROM photos
    WHERE ACCESS_RIGHT='PUBLIC'
    AND CONTAINS(TEXT_DESCRIPTION,'Melbourne',1)> 0
    AND CONTAINS(TEXT_DESCRIPTION,'2005',2)> 0
    ORDER BY USER_ID,score(1) DESC;

    I use a third part product to do this (irfanview.exe).
    This tool allows to do some batch operation /print to print the file)
    Francois

  • How to send JPG images in MAIL?

    I'm having a problem in sending JPG files in MAIL. Nobody can open de files i send. Need Help.
    Tanks.

    Makes sure extensions are fully apparent, checks the form of preview that may have been created on the Mac for its use. Two support documents are linked below, and the one for earlier version of Mail is still useful:
    http://docs.info.apple.com/article.html?path=Mail/4.0/en/9965.html
    and
    http://docs.info.apple.com/article.html?path=Mail/3.0/en/9965.html
    If you were sending to someone using a really old version Mac OS, it might be a hinderance, btw.
    The issues that can arise from use of Rich Text Format are separate issues, and relate to MS and AOL not processing RTF from other systems.
    Ernie
    Message was edited by: Ernie Stamper

  • How to compact .JPG images

    With Thunderbird running on Windows, I had an option where I could compact the data size of attached images before I sent them. Now that I have moved to a Mac, I would like to have the same option. What do I have to do to add this function to my Thunderbird on the Mac? (Running OS 10.9 Mavericks)
    Thanks for your help,
    Bernard

    Try one of these add-ons:
    https://addons.mozilla.org/en-US/thunderbird/addon/auto-resize-image/
    https://addons.mozilla.org/en-US/thunderbird/addon/shrunked-image-resizer/
    http://chrisramsden.vfast.co.uk/3_How_to_install_Add-ons_in_Thunderbird.html

  • How can I get a tab to open in an oversize jpg image in its original size with scroll bars when I click on a link?

    I have a small program for storing my genealogy names and jpg images of the census pages where each name is found. The images have a thumbnail link that opens in a new tab to view the actual oversized census page. In the new tab the census page is small and not readable. How do I get the jpg image to appear in its original size with schroll bars so I can read the census in the firefox browser without using the zoom feature. It takes several clicks on the zoom to get the image to a readable size and that is time consuming, especially when I have several images opened.

    That works, thank you!
    Could I suggest that this feature (the ability to turn off or turn on the auto-resize of images) be part of the Options tab on Firefox? I think it's a setting that some users might want to change fairly often--even toggle back and forth on. It's a little annoying to have to go into about:config every time to do this.

  • I am exporting a Pages document to Epub and Pages is compressing my jpg images.  How do I keep the original jpg size during the export to epub process?

    I am exporting a Pages document to Epub and Pages is compressing my jpg images (I think to 72 dpi from original 600 dpi). 
    How do I keep the original jpg size during the export to epub process?

    We are still trying learn how to use Pages to build ePub documents with high resolution graphics that will expand clearly when they are tapped. Very large screen shots are my example here.

  • How to save 4 artboards as 1 JPG image in Adobe Illustrator?

    I am doing an online class for fundamentals of design.
    I had to create 4 different designs, so I did this by doing them on 4 different artboards.
    I need to save my work for "web and devices..." as a JPG image in Adobe Illustrator (this i can do). But I want to save this assignment as 1 JPG image with all four artboards showing on one image.
    Can anyone tell me how to do this step by step.
    Thanks so much!!!
    Oh I am using Adobe Illustrator CS5.1

    Make a new artboard by selecting the Artboard tool and shift-click where you want it to start, then drag it out to cover all four of the images.

  • Premier pro cs6: how to use 400 jpg images to make a movie?

    I want to use about 400 jpg images to make a movie.  is there a way to add them to a sequence in a random order?

    I'm not aware of a randomize feature either, but here is a suggested workflow that may make it easier than shuffling 400 images around in Premiere:
    Open your images in Bridge
    Move them around to meet your random requirement
    Highlight all images (Ctrl-A)
    Right-click / batch rename and add a sequence number to the front of each name (I like to add a text "_" too) and copy the resulting set of images to an empty directory
    Import the whole directory into Premiere
    Automate to timeline
    I used to use Liquid and it had a wonderful freestyle way to pre-order your clips or images prior to dumping them onto your timeline, and the above workflow is how I have come to approximate the same.
    Regards,
    Jim

  • How do I transfer jpg images transfered to an SD card, into an iPad?

    How do I transfer jpg images transfered to an SD card, into an iPad? Have tried lots - nothing works.
    I would like to buy an iPad if this could be solved.
    I am on a PC
    I have iTunes on my desptop, not my laptop.
    When traveling I shoot RAW 22mg photos.
    I resize down to 2mg file for screen.
    I transfer to SD card to then transfer to an iPad.
    I use wifes new iPad with SD card accessory to try to get it to work but it doesn't.
    I created a test directory with subdirectories
    Synced it to iPhone 3GS and worked fine.
    Will not do syncing from laptop because ...no iTunes anddon't want it on laptop.
    Did experiment with wife's MAC desktop - it worked fine
    Card is an SD HC which supposedly works fine.
    Apple would have a customer if I could do this.
    Thanks for any possible solutions.
    Brad

    Meg:
    So far you are leading the race. I tried more scenarios on the SD card and the DCIM + names no longer than 8 characters works. However this naming and sorting convention still falls short for me. I realize what we want and what we get are sometimes two different things and I always try to seek a workaround.
    If I breakdown and install iTunes on my laptop and sync just my main directory with many longer than 8 chars sub directory names and within those many jpg's with longer than 8 chars names would that solve my dilemma?...like how it works on the iPhone?
    On the recent test with the SD attachment the sub directories did not import or even show - only those in the root. I named one sub directory with only 8 chars and one file inside less than 8 chars - not found by iPad.
    I am hesitant to do this (add iTunes to laptop) because I may not necessarily want all files synced on desktop, laptop and iPad.
    I sort many files based on events and travel days and most of the events I do are several days, hence many subdirectories...sometimes 5 weeks gone.
    Sorry to be a pain but I am trying to buy an iPad...but so far not practical reason.
    Brad

  • How do I play back jpg images quickly

    I created a series of jpg images as an animation project. I now have 600 jpg images and want to create an 18 second clip with them. When I imported them into Premiere Pro CS5.5, and then added them to my timeline they each play for 5 seconds. I need for them to play at .03 seconds each to create the 18 second clip. How do I change the length of time each is displayed in Premiere Pro CS5?

    For easy searching, download the product user guide PDF(s)
    The individual CS5 pages also have links to the earlier user guide pages
    CS5 User Guides - online and PDF (right click PDF link to save PDF to your hard drive)
    http://blogs.adobe.com/premiereprotraining/2010/08/help-documents-for-creative-suite-5-pdf -and-html.html
    The July 12 2010 CS5 user guide I downloaded has the information you want on page 272

Maybe you are looking for