Does anybody know editing object detection in typescript?

the code for object detection from Edge impulse doc with twilio has a webserver-twilio.ts file. Does anybody know how to capture the object detected as an jpg image on typescript.
Also can we upload images detected using edge impulse to cloud platform like firebase?

Hi @finalyearproject, you get the image (as classified by the neural network) here in the imgAsJpg object (it’s a Buffer so you can just store via fs.writeFile or process directly):

You can then cut out the objects found through the coordinates in the bounding boxes array. (Sharp can do this).

how can we upload this imgAsJpg to firebase storage?

i cannot save the image, my code:

const fs = require(‘fs’);
fs.writeFile(‘image.jpg’, imgAsJpg, (err) =>{
if (err){
console.log(“image saved successfully”);

error shown:

webserver-twilio.ts:169:41 - error TS7006: Parameter ‘err’ implicitly has an ‘any’ type.

169 fs.writeFile(“elephant.jpg”,imgAsJpg,(err) =>{

Found 1 error.

Hello @finalyearproject,

This is a typescript error, can you change this line

fs.writeFile(‘image.jpg’, imgAsJpg, (err) =>{


fs.writeFile(‘image.jpg’, imgAsJpg, (err: any) =>{

Or in your tsconfig.json file you can set the parameter "noImplicitAny": false under compilerOptions.



1 Like

This is the part in my code where i used fs.writeFile:

`else if (bb.find(x => x.label === 'ELEPHANT')) {`
   ` console.log('Danger! Seeing an Elephant ');`
       `  // if last sent message >30 sec. ago?`
        `fs.writeFile(‘image.jpg’, imgAsJpg, (err: any) =>{`
           ` if(err){console.log(err);`

} else{
console.log('image saved');
if ( > lastSentMessage + 30000) {
lastSentMessage =;
try {
await twilioClient.messages.create({
await twilioClient.messages.create({
body: 'Alert! An Elephant has entered the Farmland',
to: process.env.TWILIO_TO || '',
from: process.env.TWILIO_FROM || ''
catch (ex2) {
let ex = <Error>ex2;
console.warn('Failed to send a message via Twilio', ex.message || ex.toString());
This error shows up:

webserver-twilio.ts:171:16 - error TS1127: Invalid character.

171 fs.writeFile(‘image.jpg’, imgAsJpg, (err: any) =>{

webserver-twilio.ts:171:26 - error TS1127: Invalid character.

171 fs.writeFile(‘image.jpg’, imgAsJpg, (err: any) =>{

webserver-twilio.ts:171:27 - error TS1135: Argument expression expected.

171 fs.writeFile(‘image.jpg’, imgAsJpg, (err: any) =>{

Found 3 errors.

Hello @finalyearproject,

I’ve just seen that you are using quotes instead of ' here ‘image.jpg’

This is why you have an invalid character error.


Yes, I got it thanks.
my goal is to create a website and display the images taken from the Rpi in that website. I have already hosted a dummy website on firebase. Also firebase supports Firebase Storage Feature which could help me store the image in the cloud. But I don’t know how to upload the images from the Rpi to firebase storage automatically and display them on the website. Do you have an idea on how to do it?
since the webserver-twilio.ts is a not a language I’m familiar with. Any suggestions?

@finalyearproject You can also use the model files from Python, Go and C++ if that’s more your thing - e.g. see .