Esempio n. 1
0
    /* scanning for devices */
void pa_getdevs(char *indevlist, int *nindevs,
    char *outdevlist, int *noutdevs, int *canmulti, 
        int maxndev, int devdescsize)
{
    int i, nin = 0, nout = 0, ndev;
    *canmulti = 1;  /* one dev each for input and output */

    pa_init();
    ndev = Pa_GetDeviceCount();
    for (i = 0; i < ndev; i++)
    {
        const PaDeviceInfo *pdi = Pa_GetDeviceInfo(i);
        if (pdi->maxInputChannels > 0 && nin < maxndev)
        {
            sprintf(indevlist + nin * devdescsize, "(%d)%s",
                pdi->hostApi,pdi->name);
            /* strcpy(indevlist + nin * devdescsize, pdi->name); */
            nin++;
        }
        if (pdi->maxOutputChannels > 0 && nout < maxndev)
        {
            sprintf(outdevlist + nout * devdescsize, "(%d)%s",
                pdi->hostApi,pdi->name);
            /* strcpy(outdevlist + nout * devdescsize, pdi->name); */
            nout++;
        }
    }
    *nindevs = nin;
    *noutdevs = nout;
}
Esempio n. 2
0
int main(int n, char **args){
  pa_init(n,args,"[m]-input|-i(2) -rectification|-r -create-crop-rect-output-only|-ccroo|-c "
          "-estimate-image-size-only -estimate-image-ar-only "
          "-compute-optimal-scaling-size(target-width) -compute-optimal-scaling-size-input-size(Size=0x0)");
  if(pa("-estimate-image-size-only").as<bool>() || pa("-estimate-image-ar-only").as<bool>() || pa("-compute-optimal-scaling-size").as<bool>()){
    GenericGrabber g(pa("-input"));
    Size s = g.grab()->getSize();
    if(pa("-estimate-image-size-only")){
      std::cout << s << std::endl;
    }
    if(pa("-estimate-image-ar-only")){
      std::cout << float(s.width)/float(s.height) << std::endl;
    }
    if(pa("-compute-optimal-scaling-size")){
      int W = pa("-compute-optimal-scaling-size");
      Size sinput = pa("-compute-optimal-scaling-size-input-size");
      if(sinput == Size(0,0)) sinput = s;
      float f = float(W)/float(sinput.width);
      std::cout << Size(W,round(sinput.height * f)) << std::endl;
    }

    return 0;
  }
  ICLApp app(n,args,"",init,run);
  int result = app.exec();
  std::cout << lastRect << std::endl;
  return result;
}
Esempio n. 3
0
int main(int argc, const char * argv[])
{
    plotter_init();
    pa_init();
    getchar();
    pa_close();
    plotter_close();
    return 0;
}
Esempio n. 4
0
int main(int n, char **ppc){
  pa_explain
  ("-i","the first sub-argument defines the marker type (one of bch, icl1 and art). The 2nd sub-argument "
   "defines which marker to create (this is the marker ID in case of type bch and icl1 and "
   "in case of makrer type art, an image filename is expected")
  ("-b","border width, which is only relevant for bch markers (the detectors default value is 2)")
  ("-r","border ratio, which is only relevant for art markers (the detectors default is value is 0.4)")
  ("-o","optionally given output filename. If this is not given, the marker image is shown instead")
  ("-s","output size of the marker image");
  

  pa_init(n,ppc,"-id|-i(type,int) -border-size|-b(int=2) "
          "-border-ratio|-r(float=0.4) -output|-o(filename) "
          "-size|-s(size=300x300) "
          "-show-valid-icl1-codes");

  if(pa("-show-valid-icl1-codes")){
    std::vector<MarkerCodeICL1> cs = MarkerCodeICL1::generate();
    std::sort(cs.begin(),cs.end());
    std::cout << "icl1 marker codes with minimal hamming distance > 1" << std::endl;
    for(size_t i=0;i<cs.size();++i){
      if(i<10) std::cout << " ";
      std::cout << i << ": " << cs[i] << std::endl;
    }
    return 0;
  }else{
    if(!pa("-i")){
      pa_show_usage("please define marker type and ID using '-i type id'");
      return -1;
    }
  }

  
  FiducialDetector d(*pa("-i"));
  ParamList params;
  if(*pa("-i") == "art"){
    params = ParamList("border ratio",*pa("-r"));
  }else if(*pa("-i") == "bch"){
    params = ParamList("border width",*pa("-b"));
  }
  Img8u image = d.createMarker(*pa("-i",1), pa("-s"), params);

  if(pa("-o")){
    save(image,*pa("-o"));
  }else{
    show(image);
  }

}
Esempio n. 5
0
    /* scanning for devices */
void pa_getdevs(char *indevlist, int *nindevs,
    char *outdevlist, int *noutdevs, int *canmulti,
        int maxndev, int devdescsize)
{
    int i, nin = 0, nout = 0, ndev;
    *canmulti = 1;  /* one dev each for input and output */

    pa_init();
    ndev = Pa_GetDeviceCount();
    for (i = 0; i < ndev; i++)
    {
        const PaDeviceInfo *pdi = Pa_GetDeviceInfo(i);
        if (pdi->maxInputChannels > 0 && nin < maxndev)
        {
                /* LATER figure out how to get API name correctly */
            snprintf(indevlist + nin * devdescsize, devdescsize,
#ifdef _WIN32
     "%s:%s", (pdi->hostApi == 0 ? "MMIO" : (pdi->hostApi == 1 ? "ASIO" : "?")),
#else
#ifdef __APPLE__
             "%s",
#else
            "(%d) %s", pdi->hostApi,
#endif
#endif
                pdi->name);
            nin++;
        }
        if (pdi->maxOutputChannels > 0 && nout < maxndev)
        {
            snprintf(outdevlist + nout * devdescsize, devdescsize,
#ifdef _WIN32
     "%s:%s", (pdi->hostApi == 0 ? "MMIO" : (pdi->hostApi == 1 ? "ASIO" : "?")),
#else
#ifdef __APPLE__
             "%s",
#else
            "(%d) %s", pdi->hostApi,
#endif
#endif
                pdi->name);
            nout++;
        }
    }
    *nindevs = nin;
    *noutdevs = nout;
}
Esempio n. 6
0
int main(int argc, const char * argv[])
{
    float coeffs[NUM_COEFFS] = {0.00460399444634034,
                                0.00920798889268068,
                                0.00460399444634034,
                                -1.7990948352036205,
                                0.8175108129889816};
    int i;
    for (i=0; i<FILTERS;i++) {
        bq[i] = bq_new(coeffs);
    }
    pa_init();
    getchar();
    pa_close();
    free(bq);
    return 0;
}
Esempio n. 7
0
static int engine_start(PaStreamParameters *sp)
{
    rsound *rsnd;

    rsnd = (rsound *)malloc(sizeof(rsound));
    rsnd->running = 0;

    if (pa_init(rsnd) != 0) {
        Pa_Terminate();
        domain_error("pa_init");
    }

    if (pa_setsp(rsnd, sp) != 0) {
        Pa_Terminate();
        domain_error("pa_setsp: No default output device.");
    }

    return 0;
}
Esempio n. 8
0
int as_parse (ATTSET *set, SCAN *scan, int types)
{                               /* --- parse att. set description */
  int r, err = 0;               /* result of function, error flag */

  assert(set);                  /* check the function argument */
  pa_init(scan);                /* initialize parsing */
  if (types & AT_ALL) {         /* if at least one type flag is set */
    while (1) {                 /* read loop (with recovery) */
      r = _domains(set, scan, types);   /* read att. domains */
      if (r == 0) break;        /* if no error occurred, abort */
      err = r;                  /* otherwise set the error flag */
      if (r == E_NOMEM) break;  /* always abort on 'out of memory' */
      sc_recover(scan, ';', 0, 0, 0);
    }                           /* otherwise recover from the error */
    if (err) return -1;         /* read domain definitions */
  }                             /* and check for an error */
  if (set->attcnt <= 0) ERR_STR("dom");
  return err;                   /* return error flag */
}  /* as_parse() */
Esempio n. 9
0
int main (int argc, char **argv) {
  pa_explain("-input","generic-grabbers generic grabbers params")
            ("-config","config file input")
            ("-size","grabbers desired image size")
            ("-nogui","start without gui")
            ("-output","for no gui batchmode: define output-image pattern\n"
             "use ##### for the image index in this pattern");

  pa_init(argc,argv,"[m]-input|-i(device,device-params) "
          "-output|-o(output-file-pattern) -config|-c(cfg-filename) "
          " -nogui|-n -color -size|-s(size=VGA)");
  
  
  if(pa("-nogui")){
    batch_mode();    
  }else{
    return ICLApp(argc,argv,"",init,run).exec();
  }
}
/**
 * The main function for the record helper.
 *
 * @param argc number of arguments from the command line
 * @param argv command line arguments
 * @return 0 ok, 1 on error
 */
int
main (int argc, char *argv[])
{
  GNUNET_assert (GNUNET_OK ==
		 GNUNET_log_setup ("gnunet-helper-audio-record",
				   "WARNING",
				   NULL));
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
	      "Audio source starts\n");
  audio_message = GNUNET_malloc (UINT16_MAX);
  audio_message->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);

#ifdef DEBUG_RECORD_PURE_OGG
  dump_pure_ogg = getenv ("GNUNET_RECORD_PURE_OGG") ? 1 : 0;
#endif
  ogg_init ();
  opus_init ();
  pa_init ();
  return 0;
}
Esempio n. 11
0
int main(int n, char **a){
  pa_explain("-o","output filename (should be some format, that supports alpha channel such as png)\n"
             "or, if no output is given, the image is just show");
  pa_init(n,a,"-icon-name|-i(iconname=empty) -output|-o(2) -image-file-to-c++-array|-ita(input-file-name)");
  
  if(pa("-ita")){
    Img8u image = load<icl8u>(pa("-ita"));
    const int w=image.getWidth(), h = image.getHeight(), c = image.getChannels();
    std::cout << "static icl8u data_XYZ["<<w<<"]["<<h<<"]["<<c<<"]={" << std::endl; 
    for(int y=0;y<h;++y){
      std::cout << "{";
      for(int x=0;x<w;++x){
        std::cout << "{";
        for(int i=0;i<c;++i){
          std::cout << (int)image(x,y,i) << (i<c-1?",":"}");
        }
        std::cout << (x<w-1?",":"}");
      }
      std::cout << (y<h-1?",":"};") << std::endl;
    }
    std::cout << "//#include <ICLCore/Img.h>" << std::endl;
    std::cout << "//#include <ICLCC/CCFunctions.h>" << std::endl;
    std::cout << "const Img8u& load_data_XYZ(){" << std::endl;
    std::cout << "  static SmartPtr<Img8u> image;" << std::endl;
    std::cout << "  if(!image){" << std::endl;
    std::cout << "     image = new Img8u(Size(" << w << "," << h << ")," << c << ");" << std::endl;
    std::cout << "     interleavedToPlanar((const icl8u*)data_XYZ, image.get());" << std::endl;
    std::cout << "  }" << std::endl;
    std::cout << "  return *image;" << std::endl;
    std::cout << "}" << std::endl;
  }else{
    const Img8u &image = IconFactory::create_image(pa("-i"));
    
    if(pa("-o")){
      GenericImageOutput out(pa("-o"));
      out.send(&image);
    }else{
      show(image);
    }
  }
}
Esempio n. 12
0
void pa_listdevs(void)     /* lifted from pa_devs.c in portaudio */
{
    int      i,j;
    int      numDevices;
    const    PaDeviceInfo *pdi;
    PaError  err;
    pa_init();
    numDevices = Pa_GetDeviceCount();
    if( numDevices < 0 )
    {
        fprintf(stderr, "ERROR: Pa_GetDeviceCount returned %d\n", numDevices );
        err = numDevices;
        goto error;
    }
    fprintf(stderr, "Audio Devices:\n");
    for( i=0; i<numDevices; i++ )
    {
        pdi = Pa_GetDeviceInfo( i );
        fprintf(stderr, "device %d:", i+1 );
        fprintf(stderr, " %s;", pdi->name );
        fprintf(stderr, "%d inputs, ", pdi->maxInputChannels  );
        fprintf(stderr, "%d outputs", pdi->maxOutputChannels  );
        if ( i == Pa_GetDefaultInputDevice() )
            fprintf(stderr, " (Default Input)");
        if ( i == Pa_GetDefaultOutputDevice() )
            fprintf(stderr, " (Default Output)");
        fprintf(stderr, "\n");
    }

    fprintf(stderr, "\n");
    return;

error:
    fprintf( stderr, "An error occured while using the portaudio stream\n" ); 
    fprintf( stderr, "Error number: %d\n", err );
    fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );

}
Esempio n. 13
0
short vga_init()
{
	// Only do this function once!
	if (vga_installed==1)
		return 1;

#if !defined(POLY_ACC)
	if (gr_init_A0000())
		return 10;
#endif

	vga_screen_addr = (ubyte *)0xa0000;		//address in memory of screen

	// Save the current text screen mode
	if (vga_save_mode()==1)
		return 1;

/*	if (get_selector( &vga_fade_table, 256*GR_FADE_LEVELS, &vga_fade_table_selector ))
		Error( "Error allocating fade table selector!" );

	if (get_selector( &vga_palette, 256*3, &vga_palette_selector ))
		Error( "Error allocating palette selector!" );

	if (get_selector( &vga_inverse_table, 32*32*32, &vga_inverse_table_selector ))
		Error( "Error allocating inverse table selector!" );
*/

	// Set flags indicating that this is installed.
//	gr_palette_clear();
	vga_installed = 1;
	atexit(vga_close);

#if defined(POLY_ACC)
    pa_init();
#endif
	return 0;
}
Esempio n. 14
0
int pa_open_audio(int inchans, int outchans, int rate, t_sample *soundin,
    t_sample *soundout, int framesperbuf, int nbuffers,
    int indeviceno, int outdeviceno, t_audiocallback callbackfn)
{
    PaError err;
    int j, devno, pa_indev = -1, pa_outdev = -1;
    
    pa_callback = callbackfn;
    /* fprintf(stderr, "open callback %d\n", (callbackfn != 0)); */
    pa_init();
    /* post("in %d out %d rate %d device %d", inchans, outchans, rate, deviceno); */
    
    if (pa_stream)
        pa_close_audio();

    if (inchans > 0)
    {
        for (j = 0, devno = 0; j < Pa_GetDeviceCount(); j++)
        {
            const PaDeviceInfo *info = Pa_GetDeviceInfo(j);
            if (info->maxInputChannels > 0)
            {
                if (devno == indeviceno)
                {
                    if (inchans > info->maxInputChannels)
                      inchans = info->maxInputChannels;

                    pa_indev = j;
                    break;
                }
                devno++;
            }
        }
    }   
    
    if (outchans > 0)
    {
        for (j = 0, devno = 0; j < Pa_GetDeviceCount(); j++)
        {
            const PaDeviceInfo *info = Pa_GetDeviceInfo(j);
            if (info->maxOutputChannels > 0)
            {
                if (devno == outdeviceno)
                {
                    if (outchans > info->maxOutputChannels)
                      outchans = info->maxOutputChannels;

                    pa_outdev = j;
                    break;
                }
                devno++;
            }
        }
    }   

    if (inchans > 0 && pa_indev == -1)
        inchans = 0;
    if (outchans > 0 && pa_outdev == -1)
        outchans = 0;
    
    if (sys_verbose)
    {
        post("input device %d, channels %d", pa_indev, inchans);
        post("output device %d, channels %d", pa_outdev, outchans);
        post("framesperbuf %d, nbufs %d", framesperbuf, nbuffers);
    }
    pa_inchans = sys_inchannels = inchans;
    pa_outchans = sys_outchannels = outchans;
    pa_soundin = soundin;
    pa_soundout = soundout;

    if (pa_inbuf)
        free(pa_inbuf), pa_inbuf = 0;
    if (pa_outbuf)
        free(pa_outbuf), pa_outbuf = 0;
    
    if (! inchans && !outchans)
        return (0);
    
    if (callbackfn)
    {
        pa_callback = callbackfn;
        err = pa_open_callback(rate, inchans, outchans,
            framesperbuf, nbuffers, pa_indev, pa_outdev, pa_lowlevel_callback);
    }
    else
    {
        if (pa_inchans)
        {
            pa_inbuf = malloc(nbuffers*framesperbuf*pa_inchans*sizeof(float));
            sys_ringbuf_Init(&pa_inring,
                nbuffers*framesperbuf*pa_inchans*sizeof(float), pa_inbuf,
                    nbuffers*framesperbuf*pa_inchans*sizeof(float));
        }
        if (pa_outchans)
        {
            pa_outbuf = malloc(nbuffers*framesperbuf*pa_outchans*sizeof(float));
            sys_ringbuf_Init(&pa_outring,
                nbuffers*framesperbuf*pa_outchans*sizeof(float), pa_outbuf, 0);
        }
        err = pa_open_callback(rate, inchans, outchans,
            framesperbuf, nbuffers, pa_indev, pa_outdev, pa_fifo_callback);
    }
    if ( err != paNoError ) 
    {
        fprintf(stderr, "Error number %d opening portaudio stream\n",
            err); 
        fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
        Pa_Terminate();
        return (1);
    }
    else if (sys_verbose)
        post("... opened OK.");
    return (0);
}
Esempio n. 15
0
int main(int n, char **ppc){
  pa_explain
  ("-p","specifies image to create.\n"
   "Also possible: first unspecified argument.\n"
   "One of house,tree,parrot,windows, or flowers")
  ("-o","specifies output image name (filetype be extension)\n"
   "Also pssible: 2nd unspecified argmunet.\n")
  ("-d","defines output image depth")
  ("-f","defines output image format")
  ("-s","defines output image size (incompatible to -scale)")
  ("-sc","defines output scale factor (incompatibel to -size)");
  pa_init(n,ppc,"-o|-output(filename) -pattern|-p(pattern=parrot) "
          "-size|-s(Size) -depth|-d(depth=depth8u) -format|-f(format=rgb) "
          "-scale|-sc(scalefactor=1.0)",true);

  std::string patternName,outFileName;

  
  if( pa("-p") && pa_get_count()){
    pa_show_usage("if patterns are defined using -p or -pattern, dangling arguments are not allowed");
    exit(-1);
  }
  patternName = pa_get_count() ? *pa(0) : *pa("-p");

  if(pa_get_count() > 2){
    pa_show_usage("only two dangling arguments are allowed");
  }  
  if(!pa("-o") && pa_get_count() < 2){
    pa_show_usage("-output or two dangling arguments are mandatory");
    exit(-1);
  }
  if(pa("-o") && pa_get_count() == 2){
    pa_show_usage("if output filename is defined using -o, dangling arguments are not allowed");
    exit(-1);
  }
  if(pa("-s") && pa("-sc")){
    pa_show_usage("arguments -size and -scale cannot be combined");
    exit(-1);
  }
  outFileName = pa_get_count()==2 ? *pa(1) : *pa("-o");
  
  ImgBase *image = new ImgQ(create(patternName));
  
  format fmt = pa("-f");
  int channels = image->getChannels();
  Size size = pa_def("-s",image->getSize());
  if(pa("-sc")){
    Size32f s32(size.width,size.height);
    s32 = s32 * (float)pa("-sc");
    size.width = round(s32.width);
    size.height = round(s32.height);
  }
  ImgParams p(size,channels,fmt);
  depth d = pa_def("-d",image->getDepth());
              
  FixedConverter conv(p,d);
  
  ImgBase *dst = 0;
  conv.apply(image,&dst);
  
  FileWriter fw(outFileName);
  fw.write(dst);
  
}