@ -110,9 +110,13 @@ MotionAwayPlugin::MotionAwayPlugin( TQObject *parent, const char *name, const TQ
kdDebug ( 14305 ) < < k_funcinfo < < " Worked! Setting Capture timers! " < < endl ;
/* Capture first image, or we will get a alarm on start */
getImage ( m_deviceHandler , m_imageRef , DEF_WIDTH , DEF_HEIGHT , IN_DEFAULT , NORM_DEFAULT ,
VIDEO_PALETTE_RGB24 ) ;
# ifdef V4L2_CAP_VIDEO_CAPTURE /* V4L2 */
V4L2_PIX_FMT_RGB24 ) ;
# else /* V4L or BSD compat layer */
VIDEO_PALETTE_RGB24 ) ;
# endif
/* We have the first image now */
/* We have the first image now */
m_tookFirst = true ;
m_wentAway = false ;
@ -142,14 +146,49 @@ void MotionAwayPlugin::loadSettings(){
int MotionAwayPlugin : : getImage ( int _dev , TQByteArray & _image , int _width , int _height , int _input , int _norm , int _fmt )
{
struct video_capability vid_caps ;
struct video_channel vid_chnl ;
struct video_window vid_win ;
struct pollfd video_fd ;
// Just to avoid a warning
_fmt = 0 ;
# if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
struct v4l2_queryctrl queryctrl ;
struct v4l2_format fmt ;
int newinput = _input ;
if ( ioctl ( _dev , VIDIOC_QUERYCTRL , & queryctrl ) = = - 1 )
{
perror ( " ioctl (VIDIOC_QUERYCTRL) " ) ;
return ( - 1 ) ;
}
if ( _input ! = IN_DEFAULT )
{
newinput = - 1 ;
if ( ioctl ( _dev , VIDIOC_S_INPUT , & newinput ) = = - 1 )
{
perror ( " ioctl (VIDIOC_S_INPUT) " ) ;
return EXIT_FAILURE ;
}
}
// Set image size
if ( ioctl ( _dev , VIDIOC_G_FMT , & fmt ) = = - 1 )
perror ( " ioctl (VIDIOC_G_FMT) " ) ;
fmt . type = V4L2_BUF_TYPE_VIDEO_CAPTURE ;
fmt . fmt . pix . width = _width ;
fmt . fmt . pix . height = _height ;
fmt . fmt . pix . field = V4L2_FIELD_ANY ;
if ( ioctl ( _dev , VIDIOC_S_FMT , & fmt ) = = - 1 )
perror ( " ioctl (VIDIOC_S_FMT) " ) ;
# elif defined(__LINUX_VIDEODEV_H) /* V4L */
struct video_capability vid_caps ;
struct video_channel vid_chnl ;
struct video_window vid_win ;
if ( ioctl ( _dev , VIDIOCGCAP , & vid_caps ) = = - 1 )
{
perror ( " ioctl (VIDIOCGCAP) " ) ;
@ -186,6 +225,8 @@ int MotionAwayPlugin::getImage(int _dev, TQByteArray &_image, int _width, int _h
if ( ioctl ( _dev , VIDIOCSWIN , & vid_win ) = = - 1 )
return ( - 1 ) ;
# endif
/* Check if data available on the video device */
video_fd . fd = _dev ;
video_fd . events = 0 ;
@ -206,10 +247,15 @@ void MotionAwayPlugin::slotCapture()
{
/* Should go on forever... emphasis on 'should' */
if ( getImage ( m_deviceHandler , m_imageNew , m_width , m_height , IN_DEFAULT , NORM_DEFAULT ,
VIDEO_PALETTE_RGB24 ) = = m_width * m_height * 3 )
# ifdef V4L2_CAP_VIDEO_CAPTURE /* V4L2 */
V4L2_PIX_FMT_RGB24
# else /* V4L or BSD compat layer */
VIDEO_PALETTE_RGB24
# endif
) = = m_width * m_height * 3 )
{
int diffs = 0 ;
if ( m_tookFirst )
if ( m_tookFirst )
{
/* Make a differences picture in image_out */
for ( int i = 0 ; i < m_width * m_height * 3 ; i + + )