Assign Image To ZKTeco Device - c#

I am trying to assign image to ZKTeco device with the model SFace900. Purpose is to recognize user on face detection. I've a SDK that works fine to download attendance from device using a C# app, in the same time I can see two default methods is given to assign image or user face as follows:
axCZKEM1.SetUserFace()
axCZKEM1.SetUserFaceStr()
I am not sure but I think it requires base64 string to transfer image to the device. So I tried something like this:
private void SetUserFaceStr(string val)
{
zkemkeeper.CZKEMClass axCZKEM1 = new zkemkeeper.CZKEMClass();
axCZKEM1.Connect_Net(IP, Port);
int idwErrorCode = 0;
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(val);
if (axCZKEM1.SetUserFaceStr(axCZKEM1.MachineNumber, userId, 50, val, byteString.Length))
{
MessageBox.Show("SetUserFaceStr!", "Success");
}
else
{
axCZKEM1.GetLastError(ref idwErrorCode);
MessageBox.Show("Operation failed,ErrorCode=" + idwErrorCode.ToString(), "Error");
}
}
The val variable is actually a base64 string that I am trying to pass. The reason I tried the above, is for this link - Assign Image or Set face. Though I failed, it throws error code 2. Is there anyone who faced the same situation or came up with a solution? This is one of my R & D project, so expecting some suggestions if this can be done.

Model: SFace900 doesnt record the face image for matching, rather it records the face template which is encrypted data of the face features. So, you can not add the face for attendance/punch recording.
You can try this with SpeedFace(AI) series models. If you want to try the cloud based api, then you can try cams utron multiface model with its own api

Related

C# GUI to Arduino: Serial Data Not Working

I'm trying to send an integer through the usb connection to my arduino. When using the sketch monitor I can verify that the code works; However, when using the C# .NET GUI, I'm unable to get anything working.
I do know that the data is sending via the LEDs lighting up on the arduino.
I'm typing an RPM into a text box, converting it to 4 bytes (integer) and writing it. Here is the GUI code:
RPMMove = Convert.ToInt32(tbRPM.Text);
byte[] bRPM = BitConverter.GetBytes(RPMMove);
port.Write(bRPM, 0, 4);
On the arduino:
void setup()
{
Serial.begin(9600);
Serial.setTimeout(100);
}
void loop()
{
while (Serial.available() > 0)
{
i = Serial.parseInt();
stepper.setRPM(i); //move motor of other library
//Serial.println(i); //I get the correct integer via the arduino monitor here.
}
}
parseInt and the fact that it works when you type the number into the console both indicate that the device wants the string sent as text. So do not use BitConverter, instead:
byte[] bRPM = Encoding.Ascii.GetBytes($"{RPMMove}\r\n");
You may need to adjust the line ending, naturally using the same one configured in your terminal emulator ("console") should work.

Getting same results with realtime database even when data has changed

I do a query on a path then add new data on the same path then read again with the same query and the new data is not in the result. I can see the new data in my FB console and if I restart my app, it will show. It's like I'm reading from cached data. What is wrong?
public static void GetScores(string readDbPath)
{
FirebaseDatabase.DefaultInstance.GetReference(readDbPath).OrderByChild("score")
.LimitToLast(Constants.FIREBASE_QUERY_ITEM_LIMIT)
.GetValueAsync().ContinueWith(task =>
{
if (task.IsFaulted)
{
// Handle the error...
Debug.LogError("FirebaseDatabase task.IsFaulted" + task.Exception.ToString());
}
else if (task.IsCompleted)
{
DataSnapshot snapshot = task.Result;
// Do something with snapshot...
List<Score> currentScoreList = new List<Score>();
foreach (var rank in snapshot.Children)
{
var highscoreobject = rank.Value as Dictionary<string, System.Object>;
string userID = highscoreobject["userID"].ToString();
int score = int.Parse(highscoreobject["score"].ToString());
currentScoreList.Add(new Score(score, userID));
}
OnStatsDataQueryReceived.Invoke(currentScoreList); // catched by leaderboard
}
});
}
It's very likely that you're using Firebase's disk persistence, which doesn't work well with Get calls. For a longer explanation of why that is, see my answer here: Firebase Offline Capabilities and addListenerForSingleValueEvent
So you'll have to choose: either use disk persistence, or use Get calls. The alternative to calling Get would be to monitor the ValueChanged event. In this case your callback will be invoked immediately when you change the value in the database. For more on this, see the Firebase documentation on listening for events.
This post was deleted stating it was just additional infos on my question. If fact it is the solution which is to use GoOffline() / GoOnline().
Thanks Frank for the detailed answer.
I tried with
FirebaseDatabase.DefaultInstance.SetPersistenceEnabled(false)
but the problem stayed the same. Using listeners is not what I want since every time a player would send a score, every player on the same path would receive refreshed data so I'm worried about b/w costs and performance.
The best solution I just found is to call before using a get
FirebaseDatabase.DefaultInstance.GoOnline();
then right after I get a response I set
FirebaseDatabase.DefaultInstance.GoOffline();
So far no performance hit I can notice and I get what I want, fresh data on each get. Plus persistence if working off line then going back.

How to change audio output device using VLC.Net

I am able to create media player like app using VLC.Net library. I am now trying to add a feature to be able to select the output device to play the media through. So far no luck.
Has anyone ever done it?
From reading the source code I would try the following. I assume you have a VlcMediaPlayer at hand and created somewhere:
void DoAudio(VlcMediaPlayer player)
{
IAudioManagement audioMgt = player.Audio;
foreach(AudioOutputDescriptions descriptions in audioMgt.Outputs.All){
foreach(AudioOutputDevice device in description.Devices){
//enumerate them for display
string audioName = device.LongName;
// Or set it as output
device.SetAsCurrent();
}
}

GoogleMap: Polyline doesn't draw all Options

On a GoogleMap I am drawing a polyline to show a route. The lat/long-data is requested via Google Directions API and I receive correct data, usually for two different cities, from which I extract the lat/long-values and add it to an Polyoptions-object, which is added to the Polyline of the Map. Whatever the route is long, how much positions/latLng are available, the route never has more than around 8 straight lines. I have read a lot of stuff, and I can be sure, that the route is created correctly, I can even delete one to create another one. I have also tried "geodesic()" with true an false. No change.
Can anybody tell how I can get out of this?
Some code snippet
polylineOptions = new PolylineOptions();
foreach (var position in routeCoordinates)
{
polylineOptions.Add(new LatLng(position.Latitude, position.Longitude));
}
gMap.AddPolyline(polylineOptions);
Added on Sept 09, 2016
I started by using the points for the legs-steps, lots of points but wrong route, so I finally used only the final overview for the route this way
if (createRouteStep == true && prop.Equals("overview_polyline"))
{
i++;
line = getPropAndValue(lines[i]);
prop = getProp(line);
propValue = getPropValue(line);
string point = propValue.Replace(com, space).Trim();//= "yhoyHg~ol#nvgBgbjAbcbByxlDr_iArqG";
startRS = new RouteStep();
startRS.RouteID = routeCounter;
startRS.StepPoints = point;
sql.insertRouteStep(startRS);
i++;
}
The code is stored in an sqlite database, from which is later retrieved and decoded. Decoding works correct, I have tried a sample (points-result in the comment above) from the mentioned Google-test-site for this purpose and the route was the same as on the site. The points from my own request for the route have the correct direction, but don't follow any road or reach the destination at all.

Play .oni-File on loop in C# / WPF

I'd like to play a previously recordet *.oni-File in C#/WPF. While, with the help of this tutorial I was able to get to RGB- and Depth-Stream to show up on my UI, I don't know how to play an *.oni-file.
The OpenNI page mentions, that I'd just have to "connect" to the file instead of the device, but I can't find the proper piece of code to do so.
The openni::Device class provides an interface to a single physical hardware device (via a driver). It can also provide an interface to a simulated hardware device via a recorded ONI file taken from a physical device.
If connecting to an ONI file instead of a physical device, it is only required that the ONI recording be available on the system running the application, and that the application have read access to this file.
I also found some clues / discussions, but none of it did help much
C# problem with .oni player
OpenNI-dev: Not able to play the skeletonRec.oni
EDIT: I found a way to at least get the recording played using the SamplesConfig.xml. I just inserted the following code into the <ProductionNodes>:
<Recording file="\test.oni" playbackSpeed="1.0"/>
Sadly, that recording crashes to program when it's done playing - I'm now looking for a way to loop the recording...
EDIT 2: Just if anybody should be interested, I'm using those lines to set the recording on loop:
ScriptNode scriptNode;
context = Context.CreateFromXmlFile(path + "\\" + configuration, out scriptNode);
Player p = (Player)context.FindExistingNode(NodeType.Player);
if (p!=null) p.SetRepeat(true); //Make sure it's really a recording.
If anybody should need the code one day - I managed to load the file and play the recording without the need of a config file:
Context context = new Context();
// Add license
License license = new License();
license.Vendor = "vendor";
license.Key = "key";
context.AddLicense(license);
// Open file
context.OpenFileRecordingEx("record.oni");
// Set to repeat
Player p = (Player)context.FindExistingNode(NodeType.Player);
if (p != null) p.SetRepeat(true);

Categories

Resources