Webcam capture & save as JPEG image

Hi,
I'm creating an application to capture image via webcam using directshow. I've managed to capture the stream using samplegrabber.
the problem is when I save the grabbed image to a JPEG, the colors are incorrect.
provided the link of the captured image from the webcam http://www.filefreak.com/pfiles/44160/test2.jpg
the right hand side of the image should be brown colored, not blue as in the picture.
I've also test to save as a bmp image, the color are ok.
this is how i save the grabbed webcam frame into a jpeg file
sampleGrabber->GetCurrentBuffer(&bufferSize, (long*)frameBuffer); 
//save into jpeg 
struct jpeg_compress_struct cinfo; 
struct jpeg_error_mgr jerr; 
JSAMPLE * image_buffer=NULL; 
FILE * outfile;      
JSAMPROW row_pointer[1];     
int row_stride;  
cinfo.err = jpeg_std_error(&jerr); 
jpeg_create_compress(&cinfo); 
if ((outfile = fopen("test2.jpg", "wb")) == NULL) { 
        fprintf(stderr, "can't open %s\n", "test2.jpg"); 
    return; 
image_buffer = (unsigned char*)frameBuffer; 
jpeg_stdio_dest(&cinfo, outfile); 
cinfo.image_width = videoWidth;      
cinfo.image_height = videoHeight; 
cinfo.input_components = 3;      
cinfo.in_color_space = JCS_RGB;      
jpeg_set_defaults(&cinfo); 
jpeg_set_quality(&cinfo, 255, TRUE ); 
jpeg_start_compress(&cinfo, TRUE); 
row_stride = videoWidth * 3;     
while (cinfo.next_scanline < cinfo.image_height) { 
    row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; 
    (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); 
jpeg_finish_compress(&cinfo); 
fclose(outfile); 
jpeg_destroy_compress(&cinfo); 
//end save jpeg 
Thanks.
Regards

Hi,
Thanks
for participating on the MSDN Forum! I think your question is mainly related
with DirectX, but not Visual C++ Language. Thus, I suggest you post your
question on the microsoft.public.win32.programmer.directx.video newsgroup, there you find DirectX experts and your
question should be answered in no time.
The people there will have enough experience with DirectX to give you the best
advice or answer!
http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.win32.programmer.directx.video&lang=en&cr=US
Thanks! Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Similar Messages

  • Webcam capture/save without $3600 NI-Vision

    I would like to use the NI-IMAQ drivers to capture a picture for a test system but my company won't purchase the vision module.  I can't blame them at $3600 per license!  There are some VIs that use system DLLs but they require .net programming, which I am not familiar with.
    Is there any way to use IMAQ without parting with all that cash?

    Hey Brock,
    Andrey is right. The NI Vision Acquisition Software 8.6.1 and the IMAQdx driver that it contains now supports USB cameras (as long as they are Direct Show compliant). With this software, you would be able to acquire images and save them to file. The IMAQdx driver still requires a license. However, because the Vision Acquisition Software does not include any of the machine vision and image processing algorithms, it has a lower price tag. Check out the Release Notes to be sure that this software will work with what you have now.
    Hope this helps.
    -Ben
    WaterlooLabs

  • Does screen saver degrade jpeg images used

    The screen saver app on my iMac uses the images stored in an Aperture library. The images are typically jpeg. Does their display in the screen saver effectively open the image then close the image thus degrading the jpeg file every time this is done?

    No. In addition, just opening a computer file almost never degrades it.
    (85737)

  • How do I save a jpeg image to kijiji in firefox?

    When I try to copy picture with a jpeg extension I am told there is a problem with the format of picture.

    How do you use the projector?
    As a school teacher I found that most projectors had moderately crummy optics.  My answer was to run the projector from my laptop.  On the laptop, I would go into full screen mode.  Didn't matter what the image was it filled the screen.  This also gave me the option of zooming in on a detail, bringing up multiple images to compare etc.
    If you have to bring the images to the club meetings on a thumb drive, then a careful crop (You probably want to do that anyway.  People who don't need to crop have names like Ansel Adams)  Now follow frank's advice and export with fit within. 

  • Unable to open saved edited jpeg image

    Not being the most techie type person, sorry if this is repeated in numerous place on the forum. I can see, and open, the images in thumbnail form in my 'Picture - Library'. I can then edit them in PE 10, but when I 'save as' (and I save as jpeg image with a version of IMG_****.jpeg copy ) the 'copy' jpeg thumbnail appears in the library as a blank page and no image. I'm then unable to open the 'saved' copy as it's the 'wrong type'. I've tried numerous images but to no avail. Any advice will be greatly appreciated.

    Change IMG_****.jpeg copy to IMG_****copy.jpeg

  • Grab jpeg images

    Hi
    I have a Java application that receives motion-jpeg stream from Axis videoserver and displays it. Now I want integrate a frame grabber; I need to grab from my capture card multiple jpeg images in order to "simulate" a motion-jpeg stream. How can I obtain this goal? JMF is useful? Jpeg conversion is efficient? I would obtain at least 5 fps (frame per second)....
    Thanx

    Hi,
    If you know the motion jpeg format of the network camera you can write a client socket to get the motion jpeg image from the camera and display it using the
    toolkit class.
    The following code may help you,
    Toolokit.getDefaultToolkit.createImage(byte []);
    The byte[] should come from socket connected to netcam.

  • How can I capture a single video frame and save as an image in PS CS6 Extended?

    I have checked similar posts on this subject, but I have a problem doing this:
    I "File>Open" a video clip [.m2ts file type] into PS CS6 Extended.
    PS sets the "Pixel Aspect Ratio" for "HDV 1080/DVCPRO HD 720 (1.33)"
    PS then warns of "Pixel Aspect Ratio Correction" for preview purposes only, and that it should be turned off for maximum image quality.
    I advance the "Timeline" to the specific frame I wish to capture.
    I simply "File>SaveAs" for a JPG image - as has been suggested.
    Both the On-screen and saved images are grossly pixelated at 1440 x 1080.
    Furthermore, the saved image is an incorrect aspect ratio - regardless of how I have the "Pixel Aspect Ratio Correction" set.
    It produced a jpg image size of 1440 x 1080 at 635 KB.
    I clearly do not know what I am doing...
    Have I missed a process - either with the file type I open, or once opened in PS CS6 and set to the desired frame?
    Adobe Bridge will display each frame in a high-quality preview - which I could be happy with, but found no capture/save tool there.
    I went back to the software that came with the video camera and saved a frame image from the video clip just fine.
    It produces a jpg image size of 2304 x 1296 at 2.63 MB with the correct aspect ratio.
    After you stop laughing ... can you let me know what I really need to do to get the correct result in PS CS6?

    Place the playhead on the frame you want as a still. Then in share window choose location Save Current Frame. You can then select options such as Jpg, PNG etc.

  • My images won't save as jpeg unless I go to Save As... what is happening to my images?

    My images look great when edited in photoshop and when I got to close and save it won't give me the option to save as a jpeg so I have to go to File Save As and then save to jpeg. But when I go to order them in Roes they look drab and awful but the thumbnail looks great. Am I saving it wrong somehow?

    Go to Image --> Mode and set image to 8 or 16 bit. If the image has 32 bit, it won't export through the save for web dialog.
    Let me know if this fixes the issue.
    Reidar

  • How to make Photoshop save Aperture imported JPEG images as JPEGs

    Recently, I upgraded from Photoshop CS 5 to CS 5.1.
    My point and shoot cameras record in JPEG format. Often, I'll import those photos into Aperture and then tweak them in Photoshop using the Edit in External Editor command. My preferences for the external editor in Aperture were set to 8-bit, Photoshop
    With Photoshop CS 5, I would edit the photo and choose Save and the edited photo would be saved back to Aperture as a new version, in a JPEG format.
    Now, using Photoshop CS 5.1, when the imported image from Aperture is converted into a PSD file and when I save back to Aperture, I end up with a PSD file.
    How can I revert to how it was before? JPEG image in Aperture, opened in external editor Photoshop as a JPEG, edited in Photoshop, then saved back to Aperture as a new version JPEG?
    (Though this question is approached in this forum, a solution to my question is never found as each dicussion ends up going off-topic from the original question)

    clapperincus wrote:
    Any further ideas from anyone who's experienced trying to open a JPEG from Aperture in Photoshop as a JPEG?
    Like I said before, you cannot open a jpeg as a jpeg, the file must be decompressed to open in PS or in Aperture, and that has always been the case.
    I do not know how it used to work, but I tested and you are correct that with PS 12.1 and with Aperture 3.2.2 a JPEG sent to open in external editor (PS) is opened into your choice of lossless format and then goes back to Aperture in the lossless format you chose.
    IMO this is the way it should be, because every save into JPEG loses image data, so such saves should be limited to the final export, in this case when the image actually leaves Aperture. If the file was compressed as a JPEG  when leaving PS, decompressed and edited in Aperture, then compressed again to export as JPEG from Aperture, unnecessary additional image data loss would occur.
    It is always better to save the application of lossy compression until the very last step in a workflow because other usages (printing, for instance) may occur before applying the lossy compression.
    -Allen

  • TS3276 Having trouble sending jpeg images as attachments in Mac email.....they go thru as images and PC users can't see the SAVE or QUICK LOOK boxes that Mac mail has.  One friend scrolled over the image, right clicked on it and saved as a PNG file.

    Having trouble sending jpeg images as attachments in Mac email.....they go thru as images and PC users can't see the SAVE or QUICK LOOK boxes that Mac mail has.  One friend scrolled over the image, right clicked on it and saved as a PNG file.

    Apple Mail isn't going to change the format of any of your attachments. it isn't going to corrupt them either.
    Exchange is a transport protocol and server. The issue you describe is not related to Exchange.
    There are many different versions of Microsoft Outlook in use and they all have e-mail bugs. Different versions have different bugs. Some Apple Mail hack to get around a bug in Outlook 2003 may cause the same message to be problematic in Outlook 2000. Fix them both and another issue will cause trouble in Outlook 2007. You can't fix this. Apple can't fix this. Microsoft can and has but that is irrelevant if your recipients are using older versions.
    One specific problem is that Apple Mail always sends image attachments inline, as images, not as iconized files. You can change this with Attachment Tamer. Just be aware that use of this software will break other things such as Stationery. E-mail is just a disaster. To date, no one outside of Apple has ever implemented the e-mail standards from 1993. Apple has continually changed its e-mail software to be more compatible with the de-facto standards that Netscape and Microsoft have unilaterally defined and people documented as "standards" after the fact. The e-mail messages that Apple Mail sends are 100% correct and do not violate any of the original standards from 1993 or the Microsoft/Netscape modifications. The problem is entirely bugs and limitations in various versions of Outlook.

  • How to save Byte Array of raw data into JPEG image.

    Hello!
    I have a image and I stored its data as byte array as
    bimage = bitmap1.getRawData();
    now I have Byte[] bimage, I want to save it as .jpeg image.
    and show that image..............

    the short way is this:
    ImageIO.write(bimage, "jpeg", new File("image.jpg"));
    Where you use the original Image object... but it has to be a java.awt.image.RenderedImage (which a java.awt.image.BufferedImage is). So this method would come in handy.
         public static BufferedImage getBufferedImage(Image img) {
              // if the image is already a BufferedImage, cast and return it
              if((img instanceof BufferedImage) && background == null) {
                   return (BufferedImage)img;
              // otherwise, create a new BufferedImage and draw the original
              // image on it
              int w = img.getWidth(null);
              int h = img.getHeight(null);
              BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
              Graphics2D g2d = bi.createGraphics();
              g2d.drawImage(img, 0, 0, w, h, null);
              g2d.dispose();
              return bi;
         }If the byte array you have is raw image data, then you can look at the javax.imageio package and see what you can do with those classes.

  • Iphoto not accepting jpeg images saved using Preview "save as"

    I have a number of tiff images on my desktop. Am trying to save them as jpeg images directly into iPhoto using the Preview "save as" function. When I do this, I can find no image in iPhoto. When I "save as" jpeg to my desktop, the jpeg image appears there and I can drag to iPhoto, but this is laborious compared with saving directly. Can anyone help me with this?

    TD, thanks for commenting on this, and I think I see your point--I used the wrong term when I wrote "import". However, in Preview there is what I see to be a "save as jpeg to iPhoto" option. Why is this available if it does not work? Or to take it from another angle--what can you do with this option? In the end, I guess my basic question is: Is there a more direct way to get tiff images into iPhoto from the desktop than saving them first to the desktop as jpeg? Apologies for piling question on question.

  • Is there anyway to suppress or disable the save as jpeg options dialog box on individiual images/pic

    Is there anyway to suppress or disable the save as jpeg options dialog box on individiual images/pictures?

    UI dialogs are an application setting, not a file property. Selectively suppressing them on a per-file basis is not possible, but you can of course create an action and suppress the dialogs...
    Mylenium

  • Save metadata in LR - degrade JPEG image quality?

    Hi:
    Does anyone know whether using the 'save metadata' feature in LR to save changed metadata to a JPEG file will result in a resaving of the entire file and/or otherwise degrade the JPEG image quality? 
    If it does not degrade the image quality, how does this feature work?
    Many thanks for the help

    Each pixel remains unchanged in this process.
    I was under the impression that any re-saving of a jpeg image results in a slight loss of quality, regardless of whether there have been changes to the image
    This is true for other editors, such as Photoshop or Photoshop Elements, but it is not true for Lightroom because, as explained, LR does things differently than other software.

  • How do I save modified RAW images in JPEG format?

    Hi,
    I have several RAW images that I mass modified with the "Camera Raw" editor (I modified one and applied the changes to all other images). How can I now save the modified images as JPEG images? I know I could open each file in Photoshop and save it as JPEG there, but that would take A LONG time.
    Thanks for any pointers!
         Mark

    They have to be opened, one by one, before the adjustments are applied and the image files saved, but the process can be automated.  For instance through the already included Image Processor, or Image Processor Pro, also pre-installed, or through Actions and Droplets you create yourself.

Maybe you are looking for