const fs = require('fs');
async function recognizeNrcCard(imagePath) {
// Convert local image file to Base64 string
const imageBuffer = fs.readFileSync(imagePath);
const base64Image = imageBuffer.toString('base64');
const payload = {
image: base64Image // Alternatively use "url": "https://..."
};
try {
const response = await fetch('https://myhuaweicloud.com', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Auth-Token': 'YOUR_HUAWEI_CLOUD_TOKEN'
},
body: JSON.stringify(payload)
});
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
const result = await response.json();
console.log("Extracted NRC Data:", result);
return result;
} catch (error) {
console.error("OCR Request Failed:", error);
}
}
Describe the bug
A clear and concise description of what the bug is.
Expected behavior
A clear and concise description of what you expected to happen.
Minimal reproducible OpenAPI snippet(if possible)
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
const fs = require('fs');
async function recognizeNrcCard(imagePath) {
// Convert local image file to Base64 string
const imageBuffer = fs.readFileSync(imagePath);
const base64Image = imageBuffer.toString('base64');
const payload = {
image: base64Image // Alternatively use "url": "https://..."
};
try {
const response = await fetch('https://myhuaweicloud.com', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Auth-Token': 'YOUR_HUAWEI_CLOUD_TOKEN'
},
body: JSON.stringify(payload)
});
} catch (error) {
console.error("OCR Request Failed:", error);
}
}
Describe the bug
A clear and concise description of what the bug is.
Expected behavior
A clear and concise description of what you expected to happen.
Minimal reproducible OpenAPI snippet(if possible)
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.