Preparing search index...

    Function extractFieldFromImage

    • Extracts and processes a specific recipe field from an image

      High-level function that combines OCR text recognition with field-specific processing and validation. Handles automatic quantity scaling, state merging, and error reporting.

      Parameters

      Returns Promise<
          Partial<
              {
                  recipeImage: string;
                  recipeTitle: string;
                  recipeDescription: string;
                  recipeTags: tagTableElement[];
                  recipePreparation: preparationStepElement[];
                  recipePersons: number;
                  recipeTime: number;
                  recipeIngredients: Partial<ingredientTableElement>[];
                  recipeNutrition: nutritionObject;
                  ingredientNames: { name: string; unit: string }[];
                  ingredientQuantities: string[];
              },
          >,
      >

      Promise resolving to partial recipe object with extracted field

      const currentState = {
      recipePreparation: [],
      recipePersons: 4,
      recipeTags: [],
      recipeIngredients: []
      };

      const result = await extractFieldFromImage(
      imageUri,
      recipeColumnsNames.ingredients,
      currentState,
      (warning) => console.warn(warning)
      );

      if (result.recipeIngredients) {
      // Ingredients extracted and scaled to current serving size
      console.log(`Extracted ${result.recipeIngredients.length} ingredients`);
      }