hello
- User
hello
- Assistant
Hello! How can I assist you today?
- User
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
hello
Hello! How can I assist you today?
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
i have a computer vision system tied to google's firestore firebase and we have developed an app to also display the number of people detected by the cv to the web app and the database for this is google's firebase firestore. assume that on my CV the uuid for firestore that we placed is "Detections" so in the firestore firebase every person detected is stored on the Detections collection.
this is my svelte web app
this is my .js file for firebase database import { collection, getDocs, onSnapshot } from "firebase/firestore"; import db from "../auth/firestore" import { writable } from "svelte/store";
export let people = writable(0)
async function getTotalNumberOfPeople() { let totalCount = [] const querySnapshot = await getDocs(collection(db, "Detections")); if(querySnapshot){ querySnapshot.forEach((doc) => { totalCount.push(JSON.parse(JSON.stringify(doc.data()))) }) }
return totalCount
}
// Set up a realtime listener to update the reactive store whenever there is new data onSnapshot(collection(db, "Detections"), (snapshot) => { people.set(snapshot.size); // updates the people count, snapshot.size gives the current number of documents }, error => { console.error(error); });
getTotalNumberOfPeople().then((out) => { if(out){ people.set(out) } }); setPeople()
export default people
so will my website app display the number of people detected and be reactive for changes as well in real time?
Your Svelte web app and the provided JavaScript file for interacting with Firebase Firestore are designed to display the number of people detected and update in real-time when changes occur in the Firestore collection named "Detections". However, some adjustments might be needed to ensure everything works as expected. Here are the key points to consider:
You are setting up a real-time Firestore listener in your JavaScript file with onSnapshot, which correctly updates the people store with snapshot.size. Whenever a new document (person detected) is added or removed from the "Detections" collection, the people store should update, causing the Svelte app to react and display the updated count.
The getTotalNumberOfPeople function retrieves the initial count of documents in the "Detections" collection. It's called once to set the initial value of people.
In the Svelte script, you subscribe to changes to the various stores (maxOccupants, terminalCapacity, units, and people). This means they will automatically invoke getCrowdnessIndicator when their values change. As a result, the UI's representation of the terminal capacity and crowd status will update.
One thing to note is that people should be a Svelte store that holds an array of person objects but you're setting it to a number with people.set(snapshot.size); This might conflict with your other logic where you expect people to be an array.
The {colorClass} in the Svelte template is within quotes and is a string and not an expression. It will not update dynamically with the variable value. Instead, you should unquote it and possibly use a class directive to apply the correct CSS class dynamically. In your Svelte app, it should be {colorClass} instead of "{colorClass}".
In your <span class="font-medium">{$people}</span>, you are trying to display the people store's value. Since the store holds an object or array (the actual people detections), displaying it directly this way may not give you the expected results. You likely want to display the number of people, so you might use ${$people.length} if people is an array.
The function setPeople() at the end of your JavaScript file doesn't appear anywhere else in the code provided, so it's unclear what its purpose is or if it's even necessary.
Assuming these points are addressed and the database connection and permissions are properly configured, the web app should be able to display the real-time number of people detected. Always ensure to test your app thoroughly to verify all interactive elements are working as expected.
Not yet included in a published release.