⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classify.cpp

📁 face recognition test source code
💻 CPP
字号:
/************************************************************************
 *                                                                      *
 *  Program package 'lvq_pak':                                          *
 *                                                                      *
 *  classify.c                                                          *
 *  -finds out the classifications against a given codebook             *
 *                                                                      *
 *  Version 3.0                                                         *
 *  Date: 1 Mar 1995                                                    *
 *                                                                      *
 *  NOTE: This program package is copyrighted in the sense that it      *
 *  may be used for scientific purposes. The package as a whole, or     *
 *  parts thereof, cannot be included or used in any commercial         *
 *  application without written permission granted by its producents.   *
 *  No programs contained in this package may be copied for commercial  *
 *  distribution.                                                       *
 *                                                                      *
 *  All comments  concerning this program package may be sent to the    *
 *  e-mail address 'lvq@cochlea.hut.fi'.                                *
 *                                                                      *
 ************************************************************************/

#include "header.h"
#include <stdio.h>
#include <float.h>
#include "lvq_pak.h"
#include "lvq.h"
#include "matlvq.h"
#include "tools.h"

static char *usage[] = {
  "classify - finds out the classifications against a given codebook\n",
  "Required parameters:\n",
  "  -cin filename         input codebook file\n",
  "  -din filename         input data\n",
  "  -dout filename        classified output data\n",
  "Optional parameters:\n",
  "  -cfout filename       output classification file\n",
  "  -buffer integer       buffered reading of data, integer lines at a time\n",
  NULL};


int compute_classifications(struct teach_params *teach, struct file_info *file)
{
  long noc;
  int label;
  struct data_entry *datatmp;
  FILE *ocf = fi2fp(file);
  struct entries *data = teach->data;
  struct entries *codes = teach->codes;
  WINNER_FUNCTION *find_winner = teach->winner;
  struct winner_info win;
  eptr p;

  if ((datatmp = rewind_entries(data, &p)) == NULL)
    {
      Msg(0, "compute_classifications: can't get data");
      return 1;
    }

  /* Number of data vectors */
  noc = data->flags.totlen_known ? data->num_entries : 0;

  /* Scan all input entries */
  while (datatmp != NULL) {

    if (find_winner(codes, datatmp, &win, 1) == 0)
      {
	/* no winner found, all components of sample masked off */
	label = find_conv_to_ind("# empty datavector");
      }
    else
      {
	label = get_entry_label(win.winner); /* use only the first label */
	set_entry_label(datatmp, label);
      }

    /* Save to file if required */
    if (ocf != NULL) {
      fprintf(ocf, "%s\n", find_conv_to_lab(label));
    }

    /* Take the next input entry */
    datatmp = next_entry(&p);

    ifverbose(1)
      if (noc)
	mprint((long) noc--);
  }
  ifverbose(1)
    {
      mprint((long) 0);
      /*fprintf(stderr, "\n");*/
    }
  return 0;
}

int classify(PLVQPARAMS params)
	{
	int ret;
	struct teach_params tparams;
	
	LVQParamstoTeach(&tparams, params);					/*Initialize the teach_param struct*/
	
	ret = compute_classifications(&tparams, NULL);
	
	return ret;
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -