/*! * recogaWritePixaa() * * Input: filename * recoga * Return: 0 if OK, 1 on error * * Notes: * (1) For each recognizer, this generates a pixa of all the * unscaled images. They are combined into a pixaa for * the set of recognizers. Each pix has has its character * string in the pix text field. * (2) As a side-effect, the character class label is written * into each pix in recog. */ l_int32 recogaWritePixaa(const char *filename, L_RECOGA *recoga) { l_int32 i; PIXA *pixa; PIXAA *paa; L_RECOG *recog; PROCNAME("recogaWritePixaa"); if (!filename) return ERROR_INT("filename not defined", procName, 1); if (!recoga) return ERROR_INT("recoga not defined", procName, 1); paa = pixaaCreate(recoga->n); for (i = 0; i < recoga->n; i++) { recog = recogaGetRecog(recoga, i); recogAddCharstrLabels(recog); pixa = pixaaFlattenToPixa(recog->pixaa_u, NULL, L_CLONE); pixaaAddPixa(paa, pixa, L_INSERT); } pixaaWrite(filename, paa); pixaaDestroy(&paa); return 0; }
/*! * \brief recogExtractPixa() * * \param[in] recog * \return pixa if OK, NULL on error * * <pre> * Notes: * (1) This generates a pixa of all the unscaled images in the * recognizer, where each one has its character class label in * the pix text field, by flattening pixaa_u to a pixa. * </pre> */ PIXA * recogExtractPixa(L_RECOG *recog) { PROCNAME("recogExtractPixa"); if (!recog) return (PIXA *)ERROR_PTR("recog not defined", procName, NULL); recogAddCharstrLabels(recog); return pixaaFlattenToPixa(recog->pixaa_u, NULL, L_CLONE); }
/*! * recogWritePixa() * * Input: filename * recog * Return: 0 if OK, 1 on error * * Notes: * (1) This generates a pixa of all the unscaled images in the * recognizer, where each one has its character string in * the pix text field, by flattening pixaa_u to a pixa. * (2) As a side-effect, the character class label is written * into each pix in recog. */ l_int32 recogWritePixa(const char *filename, L_RECOG *recog) { PIXA *pixa; PROCNAME("recogWritePixa"); if (!filename) return ERROR_INT("filename not defined", procName, 1); if (!recog) return ERROR_INT("recog not defined", procName, 1); recogAddCharstrLabels(recog); pixa = pixaaFlattenToPixa(recog->pixaa_u, NULL, L_CLONE); pixaWrite(filename, pixa); pixaDestroy(&pixa); return 0; }