[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

BOUNCE rtl@rtlinux.org: Approval required: Non-member submissionfrom [oscar <domingue@lasmea.univ-bpclermont.fr>] (fwd)



>From owner-rtl Wed May 23 08:07:49 2001
Received: from lasmea.univ-bpclermont.fr (root@lasmea.univ-bpclermont.fr [193.54.50.15])
	by hq.fsmlabs.com (8.11.2/8.11.2) with ESMTP id f4NE7mP07003
	for <rtl@rtlinux.org>; Wed, 23 May 2001 08:07:48 -0600
Received: from lasmea.univ-bpclermont.fr ([193.54.50.250])
	by lasmea.univ-bpclermont.fr (8.9.3 (PHNE_18979)/8.9.3) with ESMTP id QAA23062
	for <rtl@rtlinux.org>; Wed, 23 May 2001 16:02:49 +0200 (METDST)
Sender: oscar@lasmea.univ-bpclermont.fr
Message-ID: <3B0BC2EB.84B47DE9@lasmea.univ-bpclermont.fr>
Date: Wed, 23 May 2001 16:02:19 +0200
From: oscar <domingue@lasmea.univ-bpclermont.fr>
X-Mailer: Mozilla 4.75 [es] (X11; U; Linux 2.2.14-rtl2.3 i686)
X-Accept-Language: en,x-ns1xvubdMeeNh5,x-ns2U0e0btwUq5f
MIME-Version: 1.0
To: rtlinux mai list <rtl@rtlinux.org>
Subject: beginner
Content-Type: multipart/mixed;
 boundary="------------74C46ADD025AFC0DCEB0DEE7"

Este es un mensaje multipartes en formato MIME.
--------------74C46ADD025AFC0DCEB0DEE7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I would be agreed if someone could tell me if this is possible. I don't
know so much about rtlinux. I would make this task like a periodic task
in rtlinux and after to try to start from a linux program. 
It is possible or my idea is not a good idea. 
Can i use all things i use like if it was a linux task?
How it would be from starting this periodic task from a linux task?
Thank you and sorry if my english is not very good.
I expect that somebody could help me.
-------------
--------------74C46ADD025AFC0DCEB0DEE7
Content-Type: text/plain; charset=us-ascii;
 name="kkkkk"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="kkkkk"


#include <module.h>
#include <rtl.h>
#include </usr/src/rtl/include/rtl_sched.h>



#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/videodev.h>
#include <meteorLib.h>
//#include "evicam.h"
#include <sys/time.h>
#include <unistd.h>

extern "C" {
#include "ellipse.h"
#include "ellipse_lum.h"
#include "matrix.h"
#include "matrice_inter.h"
#include "Global_Data.h"
}

#include "commandePTZ.h"
#include "main.h"
#include <asm/io.h>


RT_TASK task;


static int AcquerirImageGdk(capture_device * pcapt_d,struct v4l2_buffer 
*pbuf,int streaming)
{
  int l,nbPlanes;
  static char init=1;
  static clock_t tempsFin=0;
  int tempsAttente;
  static Display *display;
  static XImage *ximg[STREAMBUFS];
  char  *ptrChar;
  int  *ptrInt;
  static char tabChar[FORMAT_X*FORMAT_Y*2];
  static unsigned char tabunsignedChar[FORMAT_X*FORMAT_Y/2];
  int ELL_QUADR;
  //int bidule;

  struct timeval time_out1,time_out0;
  struct timeval time_track1,time_track0;
  struct timeval time_controlPTZ1,time_controlPTZ0;
  struct timeval time_getPTZ1,time_getPTZ0;
  struct timezone tz;


  gettimeofday(&time_out0,&tz);


  if (init) {
    init_eviG21(&evi,&parametres_commande);
    fprintf(stderr,"taille_axe = %d \n",parametres_commande.taille_axe);

    display = GDK_GC_XDISPLAY(AireImage->Gc());
    nbPlanes = DisplayPlanes(display,0);
    printf("nb plans : %d\n",nbPlanes);

    //    tabChar = (char*) calloc(pcapt_d->width * pcapt_d->height,1);
    init=false;
  }


  int tx =  pcapt_d->width;
  int ty =  pcapt_d->height;


  if (capture_dq (pcapt_d, pbuf, streaming))
    {
      fprintf(stderr,"numero buffer %d \n",pbuf->index);
      // modif pour lire le dernier buffer remplit !!!!
    /*    if (pbuf->index==0)
	  {
	  bidule = 3;
	  }
	  else if (pbuf->index==1)
	  {
	  bidule = 0;
	  }
	  else if (pbuf->index==2)
	  {
	  bidule = 1;
	  }
	  else if (pbuf->index==3)
	  {
	  bidule = 2;
	  }

	  ptrInt = (int*)pcapt_d->vimage[bidule].data;*/
      ptrInt = (int*)pcapt_d->vimage[pbuf->index].data;
      //free(ptImage);
      ptImage = tabunsignedChar;//(unsigned char 
*)malloc(FORMAT_X*240*sizeof(char));
      ptrChar = tabChar;
      for (l=0;l<ty;l+=2) {
	for (int c=0;c<tx;c++) {
	  *(ptrChar++) = *(ptrInt++) ;// il lit une trame sur l'image precedente
	  *(ptrChar+tx) = *(ptrInt) ;
	  *(ptImage++) = *(ptrInt) ;
	}
	ptrChar += tx;
      }

      ptImage = tabunsignedChar;  // on met le pointeur au debut !!!
        //ptrInt = (int*)pcapt_d->vimage[pbuf->index].data;
    if (enable_track)
	{
	  gettimeofday(&time_getPTZ0,&tz);
	  evi.zoom = DonnePositionZoom();
	  evi.focus = DonnePositionFocus();
	  gettimeofday(&time_getPTZ1,&tz);
	}


      // On va te enable_tracker putain d'ellipse ou de quadrilatere...
      gettimeofday(&time_track0,&tz);
      if (nb_pt_selec_max ==3)
	{
	  ELL_QUADR =0;
#ifdef ELLIPSE_LUM
	  if(enable_track != 0) TrackEllipse_lum();

	  if (trace) trace_ellipse_lum(el_lum,0);
#else
	  if(enable_track != 0) TrackEllipse();
	  if (trace) trace_ellipse(el,0);
	 // parametres_commande.taille_axe = 2. * el.r1;
#endif

	}
      else
	{
	  ELL_QUADR =1;
	  if(enable_track != 0)  TrackQuadrilatere();
 	  if (trace) trace_quadrilatere();
	//  parametres_commande.taille_axe = sqrt( 
(gr.uf[1]-gr.uf[3])*(gr.uf[1]-gr.uf[3])+
	//					    (2.*gr.vf[1]-2.*gr.vf[3])*(2.*gr.vf[1]-2.*gr.vf[3]) );
	}
      gettimeofday(&time_track1,&tz);


      // Et maintenant on va faire bouger la camera tout seule...c'est pas 
magique, c'est scientifique...
      gettimeofday(&time_controlPTZ0,&tz);
      if (enable_track) enable_track = 2;
      if (alterne_Zoom_PanTilt)
	{
	  if (enable_track == 1)
	    {
	      CommandePositionPanTilt(&el,
				      &gr.uf[1],&gr.uf[2],&gr.uf[3],&gr.uf[4],
				      &gr.vf[1],&gr.vf[2],&gr.vf[3],&gr.vf[4],
				      ELL_QUADR,evi,parametres_commande);
	      enable_track = 2;
	    }
	  else  if (enable_track == 2)
	    {
	      // bientot sur vos ecrans le Pan-Tilt
	      PanTiltTracking(el,
			      gr.uf[1],gr.uf[2],gr.uf[3],gr.uf[4],
			      2*gr.vf[1],2*gr.vf[2],2*gr.vf[3],2*gr.vf[4],
			      ELL_QUADR,evi,parametres_commande);
	      //	  fprintf(stderr,"zoom = %d \n",evi.zoom);

	    }
	  alterne_Zoom_PanTilt = 0;
	}
      else
	{
	  if (enable_track)
	    {
	      ZoomTracking(el,
			   gr.uf[1],gr.uf[2],gr.uf[3],gr.uf[4],
			   2*gr.vf[1],2*gr.vf[2],2*gr.vf[3],2*gr.vf[4],
			   ELL_QUADR,evi,parametres_commande);
	    }
	  alterne_Zoom_PanTilt = 1;
	}
      gettimeofday(&time_controlPTZ1,&tz);

      capture_q (pcapt_d, pbuf, streaming);

    }

  AireImage->AfficheImage((unsigned char*)tabChar, 0,0,tx,ty);



  
//gdk_draw_gray_image(AireImage->w()->window,AireImage->Gc(),0,0,tx,ty,GDK_RGB_DITHER_NORMAL,(unsigned 
char*)ptrInt,tx);

  gettimeofday(&time_out1,&tz);
  fprintf(stderr,"Temps boucle = %.1f ms. (tracking = %.2f ms. PTZcontrol = 
%.2f ms. PTZget = %.2f ms.)\n",
	  
(1000000*(time_out1.tv_sec-time_out0.tv_sec)+time_out1.tv_usec-time_out0.tv_usec)/1000.,
	  
(1000000*(time_track1.tv_sec-time_track0.tv_sec)+time_track1.tv_usec-time_track0.tv_usec)/1000.,
	  
(1000000*(time_controlPTZ1.tv_sec-time_controlPTZ0.tv_sec)+time_controlPTZ1.tv_usec-time_controlPTZ0.tv_usec)/1000.,
	  
(1000000*(time_getPTZ1.tv_sec-time_getPTZ0.tv_sec)+time_getPTZ1.tv_usec-time_getPTZ0.tv_usec)/1000.
	  );
  parametres_commande.temps_boucle = 
(1000000*(time_out1.tv_sec-time_out0.tv_sec)+time_out1.tv_usec-time_out0.tv_usec)/1000.;


  return 0;
}


int init_module(void){
  rtf_create(0.4000);

  rt_task_init(&task,AcquerirImageGdk, 0,3000, 1);
  rt_task_make_periodic(&task, (RTIME)rt_get_time()+(RTIME)1000LL, 
(RTIME)(RT_TICKS_PER_SEC / 8192LL));

  return 0;
}

 void cleanup_module(void){
   rt_task_delete(&task);
   rtf_destroy(0);
 }


--------------74C46ADD025AFC0DCEB0DEE7--