jakr13
15th February 2013, 03:27
Hi Everyone,
I am a newbie who started creating a GUI for image processing in Qt4 with openCV two months back. I was successful to
1. Read an image from specific path.
2. Convert it into Grayscale image.
3. Converting grayscale image into binary thresholded image.
4. Finding the contours and drawing the contours.
5. Labeling the contours.
6. Feature extracting of the contours with its area and centroid and storing it in a text file.
Now instead of opening an image from specific path, I need to read an image from serial port. I figured out that there were some libraries for serial port in Qt, instead I implemented with win32 API. I am not certain whether I am right or wrong. Plz someone guide me in this.
My code for opening an image from specific path:
void finalv1::openimage()
{
QString filename=QFileDialog::getOpenFileName(this,tr("Load Image"),".",tr("Image Files(*.png *.jpg *.jpeg *.bmp *.tiff)"));
imageop = cvLoadImage(filename.toAscii().data());
cvNamedWindow("image",1);
cvShowImage("image",imageop);
}
void finalv1::on_pushButton_open_clicked()
{
openimage();
}
and I am processing the image with Iplimage structure.
My code for reading image from serial port using win32 API:
BOOL finalv1::openport(DCB config, const char *port)
{
hcomm=CreateFile((LPCWSTR)port,GENERIC_READ|GENERI C_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
if(GetCommState(hcomm,&config)==0)
{
return FALSE;
}
config.BaudRate = dcb.BaudRate;
config.ByteSize = dcb.ByteSize;
config.StopBits = dcb.StopBits;
config.Parity = dcb.Parity;
if(SetCommState(hcomm,&config)==0)
{
return FALSE;
}
return TRUE;
}
BOOL finalv1::readchar(unsigned char *inputdata)
{
BOOL read;
DWORD noofbytesread=0;
read = ReadFile(hcomm,inputdata,10,&noofbytesread,NULL);
if(noofbytesread==0){
return FALSE;
}
inputdata[noofbytesread]='\0';
return TRUE;
}
I am not getting any errors, but I dont know whether I am doing right and how to declare the 'input data' as IplImage structure.
Thanx!
I am a newbie who started creating a GUI for image processing in Qt4 with openCV two months back. I was successful to
1. Read an image from specific path.
2. Convert it into Grayscale image.
3. Converting grayscale image into binary thresholded image.
4. Finding the contours and drawing the contours.
5. Labeling the contours.
6. Feature extracting of the contours with its area and centroid and storing it in a text file.
Now instead of opening an image from specific path, I need to read an image from serial port. I figured out that there were some libraries for serial port in Qt, instead I implemented with win32 API. I am not certain whether I am right or wrong. Plz someone guide me in this.
My code for opening an image from specific path:
void finalv1::openimage()
{
QString filename=QFileDialog::getOpenFileName(this,tr("Load Image"),".",tr("Image Files(*.png *.jpg *.jpeg *.bmp *.tiff)"));
imageop = cvLoadImage(filename.toAscii().data());
cvNamedWindow("image",1);
cvShowImage("image",imageop);
}
void finalv1::on_pushButton_open_clicked()
{
openimage();
}
and I am processing the image with Iplimage structure.
My code for reading image from serial port using win32 API:
BOOL finalv1::openport(DCB config, const char *port)
{
hcomm=CreateFile((LPCWSTR)port,GENERIC_READ|GENERI C_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
if(GetCommState(hcomm,&config)==0)
{
return FALSE;
}
config.BaudRate = dcb.BaudRate;
config.ByteSize = dcb.ByteSize;
config.StopBits = dcb.StopBits;
config.Parity = dcb.Parity;
if(SetCommState(hcomm,&config)==0)
{
return FALSE;
}
return TRUE;
}
BOOL finalv1::readchar(unsigned char *inputdata)
{
BOOL read;
DWORD noofbytesread=0;
read = ReadFile(hcomm,inputdata,10,&noofbytesread,NULL);
if(noofbytesread==0){
return FALSE;
}
inputdata[noofbytesread]='\0';
return TRUE;
}
I am not getting any errors, but I dont know whether I am doing right and how to declare the 'input data' as IplImage structure.
Thanx!