Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9147643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:02:44+00:00 2026-06-17T11:02:44+00:00

I am trying to capture frames from a Logitech HD cam connected to a

  • 0

I am trying to capture frames from a Logitech HD cam connected to a Raspberry Pi through usb, the RP is running arch linux and I am using OpenCV C api and a TCP client.

The TCP server is running c++(QT) under ubuntu.

here is my client.c code

#include <opencv/cv.h>
 #include <opencv/highgui.h>
 #include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>


void error(char *msg)
{
    perror(msg);
    exit(0);
}

int main(int argc,char *argv[])
{

int sockfd,portno,n;
    struct sockaddr_in serv_addr;
    struct hostent *server;
    char buffer[999999];

    if(argc <3)
    {
        fprintf(stderr,"usage %s hostname portname port\n",argv[0]);
        exit(0);
    }

    portno = atoi(argv[2]);
    sockfd = socket(AF_INET , SOCK_STREAM,0);

    if(sockfd < 0)
    {
        error("ERROR OPENING SOCKET");
    }

    server = gethostbyname(argv[1]);
    if(server == NULL)
    {
        fprintf(stderr,"ERROR,NO SUCH HOST\n");
        exit(0);
    }

    bzero((char*)&serv_addr,sizeof(serv_addr));
    serv_addr.sin_family = AF_INET; 

    bcopy((char*)server->h_addr,(char*)&serv_addr.sin_addr.s_addr,server->h_length);
    serv_addr.sin_port = htons(portno);

    if(connect(sockfd,&serv_addr,sizeof(serv_addr)) < 0)
    {
        error("ERROR CONNECTING");
    }
    CvCapture *capture = cvCaptureFromCAM(1);
       // capture from cam
        int i =1;

       while ( 1 ) {
         // Get one frame
         IplImage* frame = cvQueryFrame( capture );
         if ( !frame ) {
           //fprintf( stderr, "ERROR: frame is null...\n" );
           getchar();
           break;
         }else
         {
             i++;
         }
         bzero (buffer,999999);
         strcpy(buffer,frame->imageData);
    n=write(sockfd,buffer,strlen(buffer));
    if(n <0)
    {
        error("ERROR READING FROM SOCKET");
    }
    //printf("%s\n",buffer);


    }
return 0;
}

This is how I receive data at the server:

void HostConnector::readyRead()
{
    QByteArray Data = socket->readAll();

    IplImage* frame = new IplImage();
    frame->imageData = Data.data();

    cvShowImage( "mywindow", frame ); //show the frame in a window

}

But I am receiving this error:

OpenCV Error: Bad flag (parameter or structure field) (unrecognized or
unusupported array type) in cvGetMat, file
/home/kato/GP/src/OpenCV-2.4.2/modules/core/src/array.cpp,line 2482

Qt has caught an exception thrown from an event handler. Throwing
exceptions from an event handler is not supported in Qt.You must
reimplement QApplication::notify() and catch all exceptions there

terminate called after throwing an instance of
‘cv::Exception’,error:(-206) Unrecognized or unsupported array type in
function cvGetMat.

Does anyone knows how to solve this issue ??

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:02:46+00:00Added an answer on June 17, 2026 at 11:02 am

    I think that the problem is that you are using strlen(buffer) – this function returns position of first '\0' byte, not length of buffer. Try to copy the buffer using some function for memory copying(like memcpy on windows) and as buffer length use frame->imageSize. Don’t forget to set imageSize, width and height in your image on server. Generally i would recommend to send all important information(like image width, height, etc) before first frame and than use this header without changing it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to capture frames from a Logitech HD cam connected to a
I'm trying to grab frames from a web cam using OpenCV. I also tried
I am trying to grab consecutive frames from android using opencv VideoCapture class. Actually
I am trying to detect the face from the webcam using opencv python on
I am trying to read an AVI file using openCV. After getting the capture,
I'm trying to use opencv to save frames from a webcam as jpgs or
I'm trying to process large AVI files (approx. 61000 frames, 505MB) with OpenCV, using
I trying to capture packets using SharpPcap library. I'm able to return the packets
I'm trying to capture packets from two devices on my network. I have tcpdump
I'm trying to capture audio, using the method in this question ; with AVCaptureSession

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.