Re: How to set ROI (Region of Interest)?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: How to set ROI (Region of Interest)?

koju2000

just copy and paste

 
------------------------------------------------------------------------------------------------
#include "stdafx.h"
#include <cv.h>
#include <highgui.h>
void main(int argc,char *argv[])
{
int c;
IplImage* color_img;
CvCapture* cv_cap = cvCaptureFromCAM(-1); // -1 = only one cam or doesn't matter ´Ö§¤èÒ¨Ò¡à¿ÃÁ¡Åéͧ
cvNamedWindow("Video1",1); // create window1
cvNamedWindow("Video2",1); // create window2
int x = 10;
int y = 10;
int width = 50;
int height = 50;
int add =100;
 
for(;;)
{
color_img = cvQueryFrame(cv_cap); // get frame àÍÒÃÙ»ÀÒ¾ÁÒ¨Ò¡ strucre
if(color_img != 0)

cvShowImage("Video1", color_img); // show frame1

cvSetImageROI(color_img, cvRect(x,y,color_img->width-x,color_img->height-y));
cvAddS(color_img, cvScalar(add),color_img);
cvRectangle(color_img, cvPoint(0,0),cvPoint(20,20),CV_RGB(255,255,0),0);
cvResetImageROI(color_img);
cvShowImage("Video2", color_img); // show frame2
c = cvWaitKey(10); // wait 10 ms or for key stroke
if(c == 27)
break; // if ESC, break and quit
}

/* clean up */
cvReleaseCapture( &cv_cap );
cvDestroyWindow("Video2");
cvDestroyWindow("Video1");
}
 
 
--- On Mon, 12/22/08, Entrada <[hidden email]> wrote:

From: Entrada <[hidden email]>
Subject: Re: [OpenCV] How to set ROI (Region of Interest)?
To: [hidden email]
Date: Monday, December 22, 2008, 1:07 AM






I found this lines:

newImg=cvCreateImag e(cvSize( SIDE, SIDE), IPL_DEPTH_8U , 1);
CvRect ImgROI={startX, startY, SIDE, SIDE};
cvSetImageROI( srcImg, ImgROI);
cvCopy(srcImg, newImg);
cvResetImageROI( srcImg);

Regards.
2008/12/20 yobi_gnol <gnol@galaxyserver. de>

> How can I set the ROI in a cam capture?
>
>
>

[Non-text portions of this message have been removed]

 














     

[Non-text portions of this message have been removed]


------------------------------------

Change settings: http://www.yahoogroups.com/mygroups, select
   Get Emails (get all posts)
   Daily Digest (one summary email per day)
   Read on the web (read posts on the web only)Or Unsubscribe by mailing [hidden email]
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/OpenCV/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/OpenCV/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[hidden email]
    mailto:[hidden email]

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply | Threaded
Open this post in threaded view
|

FFmpeg and OpenCV

Itu Alexandru
Hello,


In the new release(1.1) there are some classes that deal with this issue.Unfortunately I didn't have enough time to look over them.
Here is my conversion that i have used with OpenCV 1.0.
If anybody has any new implementation please share with us.:-)

void convertAvFrameToIpl(AVFrame *frame, IplImage *image)
{
 
     int nl= image->height;
     int nc= image->width * image->nChannels;
     int step= frame->linesize[0]; // because of alignment

 unsigned char *data=reinterpret_cast<unsigned char *>(image->imageData);

 for (int i=0; i<nl; i++)
 {
  for (int j=0; j<nc; j+= image->nChannels)
  {
   // 3 channels per pixel

   data[j]  = frame->data[0][j];  
   data[j+1]= frame->data[0][j+1];
   data[j+2]= frame->data[0][j+2];  
  }
  // next line
  data+= step;  
  frame->data[0]+=step;
 }
}  
 
Alex



----- Original Message ----
From: Chanin Germany <[hidden email]>
To: [hidden email]
Sent: Thursday, January 22, 2009 3:25:03 PM
Subject: Re: [OpenCV] How to set ROI (Region of Interest)?


just copy and paste

 
------------------------------------------------------------------------------------------------
#include "stdafx.h"
#include <cv.h>
#include <highgui.h>
void main(int argc,char *argv[])
{
int c;
IplImage* color_img;
CvCapture* cv_cap = cvCaptureFromCAM(-1); // -1 = only one cam or doesn't matter ดึงค่าจากเฟรมกล้อง
cvNamedWindow("Video1",1); // create window1
cvNamedWindow("Video2",1); // create window2
int x = 10;
int y = 10;
int width = 50;
int height = 50;
int add =100;
 
for(;;)
{
color_img = cvQueryFrame(cv_cap); // get frame เอารูปภาพมาจาก strucre
if(color_img != 0)

cvShowImage("Video1", color_img); // show frame1

cvSetImageROI(color_img, cvRect(x,y,color_img->width-x,color_img->height-y));
cvAddS(color_img, cvScalar(add),color_img);
cvRectangle(color_img, cvPoint(0,0),cvPoint(20,20),CV_RGB(255,255,0),0);
cvResetImageROI(color_img);
cvShowImage("Video2", color_img); // show frame2
c = cvWaitKey(10); // wait 10 ms or for key stroke
if(c == 27)
break; // if ESC, break and quit
}

/* clean up */
cvReleaseCapture( &cv_cap );
cvDestroyWindow("Video2");
cvDestroyWindow("Video1");
}
 
 
--- On Mon, 12/22/08, Entrada <[hidden email]> wrote:

From: Entrada <[hidden email]>
Subject: Re: [OpenCV] How to set ROI (Region of Interest)?
To: [hidden email]
Date: Monday, December 22, 2008, 1:07 AM






I found this lines:

newImg=cvCreateImag e(cvSize( SIDE, SIDE), IPL_DEPTH_8U , 1);
CvRect ImgROI={startX, startY, SIDE, SIDE};
cvSetImageROI( srcImg, ImgROI);
cvCopy(srcImg, newImg);
cvResetImageROI( srcImg);

Regards.
2008/12/20 yobi_gnol <gnol@galaxyserver. de>

> How can I set the ROI in a cam capture?
>
>
>

[Non-text portions of this message have been removed]
















     

[Non-text portions of this message have been removed]


------------------------------------

Change settings: http://www.yahoogroups.com/mygroups, select
   Get Emails (get all posts)
   Daily Digest (one summary email per day)
   Read on the web (read posts on the web only)Or Unsubscribe by mailing [hidden email]
Yahoo! Groups Links