Page 1 of 2 12 LastLast
Results 1 to 20 of 35

Thread: camera

  1. #1
    Join Date
    Nov 2013
    Location
    Hyderabad
    Posts
    52
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question camera

    Hello everyone
    I'm trying to design a camera, getting lot of errors...here is my project in attachments...can anyone please help me in rectifying those errors???
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: camera

    I think you might get more answers if you tell us what the error is and show us the offending piece of code instead of posting your whole large project. People might not be willing to spend their time unpacking your project, building it and going through the compilation log.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    Harini (17th December 2013)

  4. #3
    Join Date
    Nov 2013
    Location
    Hyderabad
    Posts
    52
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: camera

    actually got many errors so attaches the project...anyway here is my code

    Qt Code:
    1. #ifndef _SPLASHSCREEN_H_
    2. #define _SPLASHSCREEN_H_
    3.  
    4. #include <QPixmap>
    5. #include <QWidget>
    6. #include <QSplashScreen>
    7.  
    8. class SplashScreen : public QWidget
    9. {
    10. private:
    11. QPixmap pix;
    12. public:
    13. SplashScreen(const QPixmap &pixmap );
    14. void finish();
    15. void repaint();
    16. void showMessage(const QString &message,
    17. int alignment =Qt::AlignLeft,
    18. const QColor &color = Qt:: white);
    19. };
    20.  
    21. #endif
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. #include <QApplication>
    2. #include <QPainter>
    3. #include <QPixmap>
    4. #include <QSplashScreen>
    5. #include <QWidget>
    6.  
    7. #include "SplashScreen.h"
    8.  
    9. SplashScreen::SplashScreen(const QPixmap &pixmap ) :
    10. QWidget(0, 0,WStyle_Customize | WStyle_NoBorder | WStyle_StaysOnTop | WStyle_Tool),
    11. pix( pixmap )
    12. {
    13. setBackgroundPixmap(pix);
    14. resize( pix.size() );
    15. QRect scr = QApplication::desktop()->geometry();
    16. move( scr.center() - rect().center() );
    17. show();
    18. repaint();
    19. }
    20. void SplashScreen::repaint()
    21. {
    22. QWidget::repaint();
    23. qApp->processEvents();
    24. }
    25. void SplashScreen::finish()
    26. {
    27. close();
    28. }
    29.  
    30. void SplashScreen::showMessage(const QString &message,
    31. int alignment =Qt::AlignLeft,
    32. const QColor &color = Qt:: white);
    33. {
    34. QPixmap textPix = pix;
    35. QPainter painter( &textPix, this );
    36. painter.setPen(Qt::blue);
    37. painter.setFont(QFont("Arial", 30));
    38. QRect r = rect();
    39. r.setRect( r.x() + 10, r.y() + 10, r.width() - 20, r.height() - 20 );
    40. painter.drawText( r, alignment, message );
    41. setBackgroundPixmap( textPix );
    42. repaint();
    43. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. #ifndef MYDIALOG_H
    2. #define MYDIALOG_H
    3.  
    4. #include <QDialog>
    5. #include <QLineEdit>
    6. #include <QPushButton>
    7. #include <QLabel>
    8. #include <QComboBox>
    9.  
    10. class MyDialog : public QDialog
    11. {
    12. Q_OBJECT
    13.  
    14. public:
    15. MyDialog(QWidget *parent=0,const char *name=0,bool modal=true,Qt::WindowFlags f=0);
    16.  
    17.  
    18. QString getName();
    19.  
    20. private slots:
    21. void slotHighlighted(int);
    22. void slotSelected(int);
    23.  
    24. private:
    25. QComboBox* lb1;
    26. QString str;
    27. };
    28. #endif
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. #include <QMessageBox>
    2. #include <QDir>
    3. #include <QComboBox>
    4. #include "mydialog.h"
    5.  
    6. MyDialog::MyDialog(QWidget *parent, const char *name, bool modal,Qt:: WindowFlags f=0)
    7. :QDialog(parent,name,modal,f)
    8. {
    9. lb1 = new QComboBox(this);
    10. lb1->setGeometry(10,10,200,70);
    11.  
    12. QDir dir;
    13.  
    14. dir.setCurrent( "./" );
    15. dir.setNameFilter("*.jpg");
    16. for(int i=0;i<(int)dir.count();i++)
    17. lb1->insertItem(dir[i]);
    18.  
    19. connect(lb1,SIGNAL(selected(int)),this,SLOT(slotSelected(int)));
    20. connect(lb1,SIGNAL(highlighted(int)),this,SLOT(slotHighlighted(int)));
    21. }
    22.  
    23. QString MyDialog::getName()
    24. {
    25. return str;
    26. }
    27.  
    28. void MyDialog::slotSelected(int index)
    29. {
    30. str = lb1->text(index);
    31. accept();
    32. }
    33.  
    34. void MyDialog::slotHighlighted(int index)
    35. {
    36. str = lb1->currentText();
    37. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #ifndef WEBCAM_H
    2. #define WEBCAM_H
    3.  
    4.  
    5. #include <stdio.h>
    6. #include <string.h>
    7. #include <fcntl.h>
    8. #include <unistd.h>
    9. #include <errno.h>
    10. #include <sys/ioctl.h>
    11. #include <sys/mman.h>
    12. #include <sys/select.h>
    13.  
    14. #include <QFileDialog>
    15. #include <QPushButton>
    16. #include <QPainter>
    17. #include <QImage>
    18. #include <QPixmap>
    19. #include <QWidget>
    20. #include <QDateTime>
    21.  
    22. #include <linux/videodev.h>
    23. #include <linux/videodev2.h>
    24.  
    25. class WebCam : public QWidget
    26. {
    27. Q_OBJECT
    28. public:
    29. WebCam(const QWidget *parent=0, const char *name=0 );
    30. // WebCam::
    31. ~WebCam();
    32. QPushButton* Exit;
    33. QTimer *capt;
    34.  
    35. int video_open(const char *devname);
    36. int video_set_format(void);
    37. int video_reqbufs(void);
    38. int video_enable(int dev, int enable);
    39. int fixup_jpeg1(unsigned char *input, int input_size, unsigned char *output);
    40. void map_the_buffers();
    41. void Queue_the_buffers();
    42. void start_streaming();
    43. int i,n;
    44. protected:
    45. void paintEvent( QPaintEvent *);
    46. private slots:
    47. void slotTimeout();
    48. private:
    49. void drawImage();
    50. void changeBKImage();
    51. QTime time;
    52. QPixmap *pmBk;
    53. QPixmap *pmPaint;
    54. QImage CMOSImage;
    55.  
    56.  
    57. };
    58.  
    59. #endif // WEBCAM_H
    To copy to clipboard, switch view to plain text mode 

    [CODE]#include <QtGui/QApplication>
    #include <QWidget>
    //#include <unistd.h>
    #include "webcam.h"
    #include "SplashScreen.h"
    #include "mydialog.h"

    int main( int argc, char ** argv )
    {
    QApplication a( argc, argv );
    WebCam *usbcam = new WebCam;
    // a.setWidget(usbcam);
    usbcam->show();

    int result = a.exec();
    delete usbcam;
    return result;
    }

    Qt Code:
    1. #include <stdlib.h>
    2.  
    3. #include <QApplication>
    4. #include <QWidget>
    5. #include <QTimer>
    6. #include <QPainter>
    7. #include <QMatrix>
    8. #include <QSplashScreen>
    9. #include <QFileDialog>
    10. #include <QPushButton>
    11. #include <QImage>
    12. #include <QPixmap>
    13. #include <QDateTime>
    14. #include <QAudioOutput>
    15.  
    16. #include "webcam.h"
    17. #include "SplashScreen.h"
    18. #include "mydialog.h"
    19.  
    20. #define VAL 0
    21. #define VAL1 1
    22. static unsigned char huffman_table[] = {
    23. 0xFF,0xC4,0x01,0xA2,0x00,0x00,0x01,0x05,0x01,0x01,0x01,0x01,
    24. 0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,
    25. 0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x01,0x00,0x03,
    26. 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,
    27. 0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,
    28. ...........................................................,0xF8,0xF9,0xFA};
    29.  
    30. struct v4l2_buffer buf;
    31. unsigned int i,size,buf_size;
    32. char filename[] = "quickcam-0000.jpg";
    33. int dev, ret;
    34. FILE *file;
    35. void *mem;
    36. unsigned char data[65000];
    37. WebCam::WebCam(const QWidget *parent, const char *name)
    38. : QWidget( parent, name )
    39. {
    40. setWindowTitle("Project : Qt/E USB Camera Image capture");
    41. resize( QSize(320, 240).expandedTo(minimumSizeHint()) );
    42. //ClearState( State_Polished );
    43. video_open("/dev/video1")
    44. QPixmap pixmap("logo.png");
    45. // QSplashScreen* splash = new SplashScreen(pixmap);
    46. QSplashScreen splash(pixmap);
    47. splash.showMessage("Initialize...", 0,"Red");
    48. qApp->processEvents();
    49. sleep(3);
    50. splash.finish();
    51. splash.deleteLater();
    52. video_set_format();
    53. video_reqbufs();
    54. map_the_buffers();
    55. Queue_the_buffers();
    56. video_enable(dev,1);
    57. start_streaming();
    58. changeBKImage();
    59.  
    60. pmPaint = new QPixmap(320, 240);
    61.  
    62. capt = new QTimer( this );
    63. capt->start(1);
    64. connect( capt, SIGNAL(timeout()), SLOT(slotTimeout()) );
    65. }
    66.  
    67. WebCam::~WebCam()
    68. {
    69.  
    70. qWarning("USB-WebCamera exit!! \n");
    71. capt->stop();
    72. video_enable(dev,0);
    73. munmap(mem,buf.length);
    74. close(dev);
    75. }
    76. void WebCam::start_streaming()
    77. {
    78. memset(&buf, 0, sizeof buf);
    79. buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    80. buf.memory = V4L2_MEMORY_MMAP;
    81. ret = ioctl(dev, VIDIOC_DQBUF, &buf);
    82. if (ret < 0)
    83. {
    84. printf("Unable to dequeue buffer (%d).\n", errno);
    85. close(dev);
    86. }
    87.  
    88. // Save the image.
    89. sprintf(filename, "/root/quickcam-%03u.jpg", VAL1);
    90. file = fopen(filename, "wb");
    91. if (file != NULL)
    92. {
    93. unsigned char *input;
    94. int input_size;
    95. unsigned char *output;
    96. // int output_data;
    97. input = (unsigned char*)mem;
    98. input_size=buf.bytesused;
    99. int has_dht = 0;
    100. output = data;
    101. unsigned char hdr[4];
    102. int o_count=0;
    103. int r_count=0;
    104. int size;
    105. output[o_count++] = 0xFF;
    106. output[o_count++] = 0xD8;
    107. r_count += 2;
    108. while(!has_dht)
    109. {
    110. memcpy(hdr, input+r_count, 4);
    111. r_count += 4;
    112. if(hdr[1]==0xC4) has_dht = 1;
    113. else if(hdr[1]==0xDA) break;
    114.  
    115. // skip to the next marker
    116. size = (hdr[2]<<8) + hdr[3];
    117. memcpy(output+o_count, hdr, 4);
    118. o_count += 4;
    119. memcpy(output+o_count, input+r_count, size-2);
    120. r_count += (size-2);
    121. o_count += (size-2);
    122. }
    123.  
    124. if(!has_dht)
    125. {
    126. memcpy(output+o_count, huffman_table, sizeof(huffman_table));
    127. o_count += sizeof(huffman_table);
    128. memcpy(output+o_count, hdr, 4);
    129. o_count += 4;
    130. }
    131. // Process the remaining data in one go
    132. memcpy(output+o_count, input+r_count, input_size-r_count);
    133. o_count += (input_size-r_count);
    134. r_count += (input_size-r_count);
    135. input=NULL;
    136. output=NULL;
    137. fwrite(data,o_count,1,file);
    138. fclose(file);
    139. }
    140. // Requeue the buffer.
    141. ret = ioctl(dev, VIDIOC_QBUF, &buf);
    142. if (ret < 0)
    143. {
    144. printf("Unable to requeue buffer (%d).\n", errno);
    145. close(dev);
    146. }
    147.  
    148. fflush(stdout);
    149. }
    150. void WebCam::Queue_the_buffers()
    151. {
    152. memset(&buf, 0, sizeof buf);
    153. buf.index = VAL;
    154. buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    155. buf.memory = V4L2_MEMORY_MMAP;
    156. ret = ioctl(dev, VIDIOC_QBUF, &buf);
    157. if (ret < 0)
    158. {
    159. printf("Unable to queue buffer (%d).\n", errno);
    160. close(dev);
    161. }
    162. }
    163. void WebCam::map_the_buffers()
    164. {
    165. memset(&buf, 0, sizeof buf);
    166. buf.index = VAL;
    167. buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    168. buf.memory = V4L2_MEMORY_MMAP;
    169. ret = ioctl(dev, VIDIOC_QUERYBUF, &buf);
    170. if (ret < 0)
    171. {
    172. printf("Unable to query buffer %u (%d).\n", VAL, errno);
    173. close(dev);
    174. }
    175. printf("length: %u offset: %u\n", buf.length, buf.m.offset);
    176. mem = mmap(0, buf.length, PROT_READ, MAP_SHARED, dev, buf.m.offset);
    177. if (mem == MAP_FAILED)
    178. {
    179. printf("Unable to map buffer %u (%d)\n", VAL, errno);
    180. close(dev);
    181. }
    182. printf("Buffer %u mapped at address %p\n", VAL, mem);
    183. }
    184. int WebCam::video_set_format()
    185. {
    186. struct v4l2_format fmt;
    187. memset(&fmt, 0, sizeof fmt);
    188. fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    189. fmt.fmt.pix.width = 320;
    190. fmt.fmt.pix.height = 240;
    191. fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
    192. fmt.fmt.pix.field = V4L2_FIELD_ANY;
    193.  
    194. ret = ioctl(dev, VIDIOC_S_FMT, &fmt);
    195. if (ret < 0) {
    196. printf("Unable to set format: %d.\n", errno);
    197. return ret;
    198. }
    199.  
    200. printf("Video format set: width: %u height: %u buffer size: %u\n",
    201. fmt.fmt.pix.width, fmt.fmt.pix.height, fmt.fmt.pix.sizeimage);
    202.  
    203. return 0;
    204. }
    205. int WebCam::video_reqbufs()
    206. {
    207. struct v4l2_requestbuffers rb;
    208. memset(&rb, 0, sizeof rb);
    209. rb.count = 16;
    210. rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    211. rb.memory = V4L2_MEMORY_MMAP;
    212.  
    213. ret = ioctl(dev, VIDIOC_REQBUFS, &rb);
    214. if (ret < 0)
    215. {
    216. printf("Unable to allocate buffers: %d.\n", errno);
    217. return ret;
    218. }
    219.  
    220. printf("%u buffers allocated.\n", rb.count);
    221. return 0;
    222. }
    223. int WebCam::video_enable(int dev, int enable)
    224. {
    225. int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    226. ret = ioctl(dev, enable ? VIDIOC_STREAMON : VIDIOC_STREAMOFF, &type);
    227. if (ret < 0) {
    228. printf("Unable to %s capture: %d.\n", enable ? "start" : "stop", errno);
    229. return ret;
    230. }
    231.  
    232. return 0;
    233. }
    234. int WebCam::video_open(const char *devname)
    235. {
    236. struct v4l2_capability cap;
    237.  
    238. dev = open(devname, O_RDWR);
    239. if (dev < 0) {
    240. printf("Error opening device %s: %d.\n", devname, errno);
    241. exit(1);
    242. }
    243.  
    244. memset(&cap, 0, sizeof cap);
    245. ret = ioctl(dev, VIDIOC_QUERYCAP, &cap);
    246. if (ret < 0) {
    247. printf("Error opening device %s: unable to query device.\n",devname);
    248. close(dev);
    249. return ret;
    250. }
    251. if ((cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) {
    252. printf("Error opening device %s: video capture not supported.\n",
    253. devname);
    254. close(dev);
    255. return -EINVAL;
    256. }
    257.  
    258. printf("Device %s opened: %s.\n", devname, cap.card);
    259. return dev;
    260. }
    261. void WebCam::slotTimeout()
    262. {
    263. start_streaming();
    264. changepmBKImage();
    265. repaint(false);
    266. }
    267.  
    268. void WebCam::paintEvent( QPaintEvent * )
    269. {
    270. QPainter painter(this);
    271. drawImage();
    272. painter.drawPixmap(0, 0, *pmPaint);
    273. }
    274. void WebCam::changepmBKImage()
    275. {
    276. QString strFilename;
    277. strFilename.sprintf("/root/quickcam-%03d.jpg", VAL1);
    278. if (!pmBk.load(strFilename)) {
    279. qDebug("QPixmap load error\n");
    280. }
    281. }
    282. void WebCam::drawImage()
    283. {
    284. QMatrix matrix;
    285. QPainter painter;
    286. QString strTime;
    287. matrix.scale(-1.0,1.0);
    288. pmBk=pmBk.xForm(matrix);
    289. pmPaint->resize(width(), height());
    290. painter.begin(pmPaint, this);
    291. painter.drawPixmap(QPoint(0, 0),pmBk);
    292. painter.end();
    293. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Harini; 17th December 2013 at 12:33.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: camera

    Cool, but what is the error?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #5
    Join Date
    Nov 2013
    Location
    Hyderabad
    Posts
    52
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Re: camera

    not only one....am getting many many errors,not getting cleared....Here is the screen shotScreenshot.jpg
    Quote Originally Posted by wysota View Post
    Cool, but what is the error?

    Added after 14 minutes:


    /home/stesalit/Desktop/cam/webcam.cpp:14: error: QAudioOutput: No such file or directory
    /home/stesalit/Desktop/cam/webcam.cpp:70: error: no matching function for call to ‘QWidget::QWidget(const QWidget*&, const char*&)’
    /home/stesalit/Desktop/cam/webcam.cpp:90: error: no matching function for call to ‘QSplashScreen::finish()’

    most repeating error
    /home/stesalit/Desktop/cam/webcam.cpp:115: error: no matching function for call to ‘WebCam::close(int&)’


    /home/stesalit/Desktop/cam/webcam.cpp:139: error: conflicting declaration ‘int output’
    /home/stesalit/Desktop/cam/webcam.cpp:138: error: ‘output’ has a previous declaration as ‘unsigned char* output’
    /home/stesalit/Desktop/cam/../../qtsdk-2009.05/qt/include/QtGui/qwidget.h:783: error: ‘QWidgetData* QWidget::data’ is private
    /home/stesalit/Desktop/cam/webcam.cpp:141: error: within this context
    /home/stesalit/Desktop/cam/webcam.cpp:141: error: cannot convert ‘QWidgetData*’ to ‘unsigned char*’ in assignment
    /home/stesalit/Desktop/cam/../../qtsdk-2009.05/qt/include/QtGui/qwidget.h:783: error: ‘QWidgetData* QWidget::data’ is private
    /home/stesalit/Desktop/cam/webcam.cpp:185: error: within this context
    /home/stesalit/Desktop/cam/webcam.cpp:328: error: ‘changepmBKImage’ was not declared in this scope
    /home/stesalit/Desktop/cam/webcam.cpp:329: error: no matching function for call to ‘WebCam::repaint(bool)’
    Last edited by Harini; 18th December 2013 at 05:57.

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: camera

    Add QT += multimedia to your project file and rerun qmake. Remember, only the first error is significant, the rest may be merely a result of the compiler trying to recover from the first error.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #7
    Join Date
    Nov 2013
    Location
    Hyderabad
    Posts
    52
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: camera

    Quote Originally Posted by wysota View Post
    Add QT += multimedia to your project file and rerun qmake. Remember, only the first error is significant, the rest may be merely a result of the compiler trying to recover from the first error.
    where to add QT += multimedia in the project??

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: camera

    Quote Originally Posted by Harini View Post
    where to add QT += multimedia in the project??
    In the project file. You know... the one qmake uses.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. The following user says thank you to wysota for this useful post:

    Harini (18th December 2013)

  11. #9
    Join Date
    Nov 2013
    Location
    Hyderabad
    Posts
    52
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: camera

    but still facing the same error
    Quote Originally Posted by wysota View Post
    In the project file. You know... the one qmake uses.

  12. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: camera

    Quote Originally Posted by Harini View Post
    but still facing the same error
    Please paste your project file here, marking where you added the line. Also please state where you have the QAudioOutput file in your filesystem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #11
    Join Date
    Nov 2013
    Location
    Hyderabad
    Posts
    52
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: camera

    Quote Originally Posted by wysota View Post
    Please paste your project file here, marking where you added the line. Also please state where you have the QAudioOutput file in your filesystem.
    Actually I'm new to qt si I dont know where to add that but tried some how :P

    #include <QtGui/QApplication>
    #include <QWidget>
    //#include <unistd.h>
    #include "webcam.h"
    #include "SplashScreen.h"
    #include "mydialog.h"

    QT +=multimedia

    int main( int argc, char ** argv )
    {
    QApplication a( argc, argv );
    WebCam *usbcam = new WebCam;
    // a.setWidget(usbcam);
    usbcam->show();

    int result = a.exec();
    delete usbcam;
    return result;
    }


    Added after 5 minutes:


    Here
    Qt Code:
    1. // Save the image.
    2. sprintf(filename, "/root/quickcam-%03u.jpg", VAL1);
    3. file = fopen(filename, "wb");
    4. if (file != NULL)
    5. {
    6. unsigned char *input;
    7. int input_size;
    8. unsigned char *output;
    9. // int output_data;
    10. input = (unsigned char*)mem;
    11. input_size=buf.bytesused;
    12. int has_dht = 0;
    13. output = data;
    14. unsigned char hdr[4];
    15. int o_count=0;
    16. int r_count=0;
    17. int size;
    18. output[o_count++] = 0xFF;
    19. output[o_count++] = 0xD8;
    20. r_count += 2;
    21.  
    22. while(!has_dht)
    23. {
    24. memcpy(hdr, input+r_count, 4);
    25. r_count += 4;
    26.  
    27. if(hdr[1]==0xC4) has_dht = 1;
    28. else if(hdr[1]==0xDA) break;
    29.  
    30. // skip to the next marker
    31. size = (hdr[2]<<8) + hdr[3];
    32. memcpy(output+o_count, hdr, 4);
    33. o_count += 4;
    34.  
    35. memcpy(output+o_count, input+r_count, size-2);
    36.  
    37. r_count += (size-2);
    38. o_count += (size-2);
    39. }
    40.  
    41. if(!has_dht)
    42. {
    43. memcpy(output+o_count, huffman_table, sizeof(huffman_table));
    44. o_count += sizeof(huffman_table);
    45. memcpy(output+o_count, hdr, 4);
    46. o_count += 4;
    47. }
    48. // Process the remaining data in one go
    49. memcpy(output+o_count, input+r_count, input_size-r_count);
    50. o_count += (input_size-r_count);
    51. r_count += (input_size-r_count);
    52.  
    53. input=NULL;
    54. output=NULL;
    55. fwrite(data,o_count,1,file);
    56. fclose(file);
    57. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Harini; 19th December 2013 at 06:37.

  14. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: camera

    "Project file" is the one with "pro" extension.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #13
    Join Date
    Nov 2013
    Location
    Hyderabad
    Posts
    52
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: camera

    can I add in the beginning of the file??

  16. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: camera

    Quote Originally Posted by Harini View Post
    can I add in the beginning of the file??
    Why don't you try and see for yourself?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  17. #15
    Join Date
    Nov 2013
    Location
    Hyderabad
    Posts
    52
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: camera

    actually I'm trying for this code from last 4days.This is the last day for me to go back to my sir...so asking for help


    Added after 45 minutes:


    I have done like this....is this the correct way??

    <variable>activebuildconfiguration</variable>
    <value type="QT +=multimedia">Debug</value>
    </data>
    <data>
    Last edited by Harini; 19th December 2013 at 09:57.

  18. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: camera

    Quote Originally Posted by Harini View Post
    I have done like this....is this the correct way??
    No, this file does not have a "pro" extension. I suggest you spend one or two hours reading Qt documentation instead of blindly trying things for the next four days.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  19. #17
    Join Date
    Nov 2013
    Location
    Hyderabad
    Posts
    52
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Exclamation Re: camera

    Quote Originally Posted by wysota View Post
    No, this file does not have a "pro" extension. I suggest you spend one or two hours reading Qt documentation instead of blindly trying things for the next four days.
    I have included here in the pro file...still getting the errors.

    QT += multimedia
    TARGET = cam
    TEMPLATE = app
    SOURCES += main.cpp \
    webcam.cpp \
    SplashScreen.cpp \
    mydialog.cpp
    HEADERS += webcam.h \
    SplashScreen.h \
    mydialog.h
    FORMS +=
    OTHER_FILES += logo.png


    Added after 47 minutes:


    what does these mean and how to rectify these??

    error: within this context
    error: expected primary-expression before ‘int’
    Last edited by Harini; 21st December 2013 at 07:06.

  20. #18
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: camera

    This is not the first error. Post the first error.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  21. #19
    Join Date
    Nov 2013
    Location
    Hyderabad
    Posts
    52
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Exclamation Re: camera

    every thing got cleared finally left with these....

    /home/stesalit/Desktop/cam/webcam.cpp:90: error: expected primary-expression before ‘)’ token
    /home/stesalit/Desktop/cam/../../qtsdk-2009.05/qt/include/QtGui/qwidget.h:783: error: ‘QWidgetData* QWidget::data’ is private
    /home/stesalit/Desktop/cam/webcam.cpp:142: error: within this context
    /home/stesalit/Desktop/cam/webcam.cpp:142: error: cannot convert ‘QWidgetData*’ to ‘unsigned char*’ in assignment
    /home/stesalit/Desktop/cam/webcam.cpp:348: error: request for member ‘load’ in ‘((WebCam*)this)->WebCam:mBk’, which is of non-class type ‘QPixmap*’
    /home/stesalit/Desktop/cam/webcam.cpp:360: error: request for member ‘xForm’ in ‘((WebCam*)this)->WebCam:mBk’, which is of non-class type ‘QPixmap*’
    /home/stesalit/Desktop/cam/webcam.cpp:361: error: ‘class QPixmap’ has no member named ‘resize’
    /home/stesalit/Desktop/cam/webcam.cpp:364: error: expected primary-expression before ‘*’ token
    /home/stesalit/Desktop/cam/webcam.cpp:366: error: expected primary-expression before ‘*’ token

  22. #20
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: camera

    You have a syntax error in webcam.cpp line #89 or #90.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  23. The following user says thank you to wysota for this useful post:

    sedi (2nd January 2014)

Similar Threads

  1. Replies: 0
    Last Post: 1st July 2013, 08:59
  2. Camera Frames in UI
    By Johncdy in forum Qt Programming
    Replies: 1
    Last Post: 14th March 2011, 02:03
  3. how to connect to the camera
    By zeshu in forum Qt Programming
    Replies: 0
    Last Post: 25th November 2010, 15:15
  4. Connect camera in Qt?
    By nthung in forum Qt Programming
    Replies: 12
    Last Post: 25th May 2010, 11:19
  5. IP camera
    By vinod sharma in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2010, 13:41

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.