A am trying to get the car license plate Hikvision iDS-TCM203-A by using ISAPI. The camera admin panel allow you to recognize plate number by using the next button
The problem is I need to get that value in the NodeJS application. I have subscribed to /ISAPI/Event/notification/alertStream long polling channel, but sometimes it does not emit the license plate value from a car in camera viewport
const request = require("request");
const xml2js = require("xml2js");
const { errorData } = require("../utils/errorData");
const parser = new xml2js.Parser();
const createListener = (requestUrl, { auth, logger, onData } = {}) => {
const handlePackage = (data) => {
try {
logger.log(JSON.stringify(data));
onData(data);
} catch {
console.log("not json :-(");
}
};
return request
.get(requestUrl)
.auth(auth.username, auth.password, false)
.on("response", function (response) {
if (response.statusCode === 200) {
console.log("Listening");
logger.log("Connection opened");
response
.on("data", function (chunk) {
parser.parseString(chunk, function (err, result) {
if (!result) {
return;
}
handlePackage(result);
});
})
.on("error", (error) => {
logger.log(`Listener error: ${JSON.stringify(errorData(error))}`);
process.exit(-1);
})
.on("close", () => {
logger.log("Connection closed");
process.exit(-1);
});
} else {
logger.log(`Listener error (endpoint): code ${response.statusCode}`);
process.exit(-1);
}
})
.on("error", function (error) {
logger.log(`Listener error (request): ${JSON.stringify(errorData(error))}`);
process.exit(-1);
});
};
module.exports = { createListener }
To solve the missing license plates problem I want to spam the detect request for each 1 second. I need to get the endpoint to read all license plates from a current capture frame. The reference code is
const main = async () => {
await pb.admins.authWithPassword(POCKETBASE_ADMIN_EMAIL, POCKETBASE_ADMIN_PASSWORD).catch(() => {});
while (true) {
const image = await captureImage();
const cars = await captureLicensePlate(image);
if (!cars.length) {
fs.unlinkSync(`./public/image/${image}`);
}
for (const { licensePlate, bbox_bottom, bbox_left, bbox_right, bbox_top } of cars) {
logger.log(`DETECT CREATED licensePlate=${licensePlate} image=${image}`);
const dto = {
licensePlate,
bbox_top,
bbox_left,
bbox_right,
bbox_bottom,
image,
};
console.log(JSON.stringify(dto, null, 2))
await pb.collection("DETECT").create(dto);
}
await sleep(DETECT_TIMEOUT);
}
};
I have tried a lot of code to achieve required behavior. The /ISAPI/Traffic/channels/1/licensePlateAuditData/record?format=json
and /ISAPI/Traffic/channels/1/vehicleDetect/plates
are giving me 401 no matter if auth credentials works for /ISAPI/Event/notification/alertStream
. Could you give me an example which just works well, not googled solution which will not work especially with this camera. Maybe steps to reproduce to setup the admin panel?