7

Some of the images I get from the Webcam using fswebcam are not displaying properly.

Comparison:

enter image description hereenter image description here

I got these images using the following command:

sudo fswebcam -r 640x480 test.jpg

I'm having the same issues with 320x240 resolution.

EDIT:

I've also tried skipping some frames before getting the picture:

  sudo fswebcam -r 640x480 -S 20 test.jpg

And, although I am getting less malformed images I'm still getting a lot (1 every 6-7 taken)

What can I do to solve this output problem?

Pikamander2
  • 359
  • 3
  • 10
Gerard Rovira
  • 269
  • 2
  • 3
  • 8

6 Answers6

3

I was having a similar issue as well. To get rid of those malformed images try:

sudo fswebcam -r 640x480 test.jpg -S 2

. The -S instructs it to skip a number of frames,in this case two. Hope it helps!

alien
  • 31
  • 3
1

I am onto my second camera On my first cam I had constant broken images. They are proper files but the picture is distorted.

I am now using a Logitech c270 that i got cheap of an auction site. Initially i had some color issues because i over compensated for the previous camera.

Here is my current line

 fswebcam -d /dev/video0  -S 2 -s brightness=60% -s Contrast=15%  -s Gamma=50%  -p YUYV -r 1280x720 --jpeg 80 -s Sharpness=40% -s Saturation=15%   --title "New Zealand - Wellington - Tawa"  $DIR/$filename
user10106
  • 11
  • 1
0

Found the solution! After tweaking the motion.conf file for a couple of minutes I've came to this conclusion: NEVER use higher framerates than 30 for a webcam (30fps is more than enough to work on any decent camera, so higher fps just stresses the camera beyond its limits ). In conf. file (after installing motion, type in Cli: sudo nano /etc/motion/motion.conf), set the "framerate" to 30 and "webcam_maxrate" to 30. Problem solved!
P.S.-don't use higher resolutions than 640 x 480 !

darius
  • 1
0

@darius solution does not help at all, as it seems to be related to motion, not directly to fswebcam.

For me, using a really low framerate, and skipping frames, seems to have helped a bit (not much). Something like

fswebcam --fps 15 -S 8 -r 640x480 $DATE.jpg
0

Problem with images?

You must generate images into a directory example one image per second

/cam 20160729154102.jpg 29-Jul-2016 18:40 132K
20160729154202.jpg 29-Jul-2016 18:41 132K

and view the one generate other and delete the first

Ex: /cam.jpg in other directory

The image to view: /cam.jpg The directory with the images: /cam

When view the image, the same in totally downloading (cm.jpg) otherwise you view the last image in some time that is downloading and some times have an error.

**PHP script (execute with cron every minute)**

<meta http-equiv="refresh" content="60">
<?php
date_default_timezone_set("America/Argentina/Buenos_Aires" ) ;
?>
<!--<meta http-equiv="refresh" content="60">-->
<?
  $directory="cam";
    $dirint = dir($directory);
    while (($archivo = $dirint->read()) !== false)
    {         
      $archivos[$archivo] = $archivo; 
    }


 rsort ($archivos);


 foreach ($archivos as $archivo) {   

      $e=$e+1;

      if($e>2){

         $file='cam/'.$archivo;
          unlink($file);
      }               


 }


 foreach ($archivos as $archivo) {      

               if(preg_match('/jpg/',$archivo)){ 


                       $r=$r+1;                    
                       $alto =400;                 

                        if($r<3){
                                $file='cam/'.$archivo;                  
                            $salida = '<img src="'.$file.'">';  



                               $newfile='cam.jpg';      
                               if (!copy($file, $newfile)) {
                                echo "failed to copy<br>";
                                 }                              
                                /*
                               if (!copy($file,'capturas/'. $archivo)) {
                                echo "failed to copy<br>";
                                 }                          
                                */
                        }               


            }
 }      
    $dirint->close();


    ?>

    <div align="center">
    <?
    echo $salida;   
    ?>

    </div>

see the sample running: http://diarionecochea.mobi/camarita/camara.html

NULL
  • 2,240
  • 8
  • 28
  • 49
Luis
  • 1
0

I was getting only a dark picture (no detail at all) when I ran fswebcam image.jpg. However, I got a good picture when I ran

fswebcam --fps 15 -S 8 image.jpg

as suggested by Alexandre Strube in the answers. Thank you.