File indexing completed on 2024-05-12 05:09:21
0001 /*************************************************************************** 0002 Copyright (C) 2007-2009 Sebastian Held <sebastian.held@gmx.de> 0003 ***************************************************************************/ 0004 0005 /*************************************************************************** 0006 * * 0007 * This program is free software; you can redistribute it and/or * 0008 * modify it under the terms of the GNU General Public License as * 0009 * published by the Free Software Foundation; either version 2 of * 0010 * the License or (at your option) version 3 or any later version * 0011 * accepted by the membership of KDE e.V. (or its successor approved * 0012 * by the membership of KDE e.V.), which shall act as a proxy * 0013 * defined in Section 14 of version 3 of the license. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, * 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0018 * GNU General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 0022 * * 0023 ***************************************************************************/ 0024 0025 #ifndef BARCODE_V4L_H 0026 #define BARCODE_V4L_H 0027 0028 //#define Barcode_DEBUG 0029 0030 #include <QString> 0031 #include <QImage> 0032 0033 // since this directory only gets built if ENABLE_WEBCAM is true 0034 // we know that either libv4l >= 0.8.3 or Linux < 2.6.38 0035 #include <linux/version.h> 0036 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38) 0037 #include <linux/types.h> 0038 #include <linux/videodev.h> 0039 #else 0040 #include <libv4l1-videodev.h> 0041 #endif 0042 0043 namespace barcodeRecognition { 0044 0045 struct ng_video_fmt { 0046 unsigned int fmtid; /* VIDEO_* */ 0047 unsigned int width; 0048 unsigned int height; 0049 unsigned int bytesperline; /* zero for compressed formats */ 0050 }; 0051 enum { CAN_OVERLAY=1, CAN_CAPTURE=2, CAN_TUNE=4, NEEDS_CHROMAKEY=8 }; 0052 enum { VIDEO_NONE=0, VIDEO_RGB08, VIDEO_GRAY, VIDEO_RGB15_LE, VIDEO_RGB16_LE, 0053 VIDEO_RGB15_BE, VIDEO_RGB16_BE, VIDEO_BGR24, VIDEO_BGR32, VIDEO_RGB24, 0054 VIDEO_RGB32, VIDEO_LUT2, VIDEO_LUT4, VIDEO_YUYV, VIDEO_YUV422P, 0055 VIDEO_YUV420P, VIDEO_MJPEG, VIDEO_JPEG, VIDEO_UYVY, VIDEO_FMT_COUNT }; 0056 extern const char *device_cap[]; 0057 extern const unsigned int ng_vfmt_to_depth[]; 0058 extern const char* ng_vfmt_to_desc[]; 0059 0060 /* lookup tables */ 0061 #define CLIP 320 0062 extern unsigned int ng_yuv_gray[256]; 0063 extern unsigned int ng_yuv_red[256]; 0064 extern unsigned int ng_yuv_blue[256]; 0065 extern unsigned int ng_yuv_g1[256]; 0066 extern unsigned int ng_yuv_g2[256]; 0067 extern unsigned int ng_clip[256 + 2 * CLIP]; 0068 void ng_color_yuv2rgb_init(); 0069 0070 class barcode_v4l 0071 { 0072 public: 0073 barcode_v4l(); 0074 ~barcode_v4l(); 0075 QImage grab_one2(); 0076 bool isOpen(); 0077 0078 protected: 0079 bool grab_init(); 0080 int get_brightness_adj(unsigned char *image, long size, long *brightness); 0081 0082 QString m_devname; 0083 int m_fd; 0084 int m_grab_width, m_grab_height; 0085 video_capability m_capability; 0086 video_picture m_pict; 0087 video_window m_win; 0088 QByteArray *m_buffer; 0089 QImage *m_image; 0090 }; 0091 0092 } // namespace 0093 #endif