I am trying to getting data from mi scale V2. I am getting service data like this: “serviceData”: {“0000181b-0000-1000-8000-00805f9b34fb”: “BiTlBwcZFgsYAAAmAg==”}(5.15kg) and I decode the base64 string to array like this [66, 105, 84, 108, 66, 119, 99, 90, 70, 103, 115, 89, 65, 65, 65, 109, 65, 103, 61, 61] But I can not retrieve the correct result. How can I get the weight data?
The UUID 0000181b-0000-1000-8000-00805f9b34fb belongs to the pre-defined Body Composition Service (BCS). You can download the specification from here.
It should have the two characteristics Body Composition Feature and Body Composition Measurement.
The Features characteristic shows you the features supported by your scale, the measurement characteristic returns the actual measurement.
Take a look at this answer where I explain the process of decoding a sample weight measurement.
UUIDs with the format of 0000xxxx-0000-1000-8000-00805f9b34fb are an officially adopted Bluetooth SIG UUID and can be looked up online.
If you look at the following URL:
https://www.bluetooth.com/specifications/assigned-numbers/
there is a document with the title "16-bit UUIDs". I can see from that document that 0x181b is Body Composition GATT Service.
According to the "Body Composition Service 1.0" document at:
https://www.bluetooth.com/specifications/specs/
there should be a Body Composition Feature (0x2A9B) and a Body Composition Measurement (0x2A9C) characteristic available for that service.
It will be the Body Composition Measurement characteristic that will contain the weight value.
A generic Bluetooth Low Energy scanning and exploration tool like nRF Connect can be useful when exploring and understanding the data on a device.
Related
Problem statement: I want to scan an image at maximum scanner resolution (6400 dpi on a Epson V850). This is partly possible from the Epson scanner "professional mode" in the software, provided that the scan area is limited to 21000 x 30000 pixels.
I'm ok with this limitation, I could simply scan small squares of the full area (at max resolution), then "stitch" them together afterwards.
I want to automate this, so I'm attempting to use pyinsane / SANE.
The issue is: the maximum resolution I can set is 1200, as you can see from the properties reported by pyinsane
dps_optical_xres=6400 ([])
dps_optical_yres=6400 ([])
resolution=300 ([50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500, 525, 550, 575, 600, 625, 650, 675, 700, 725, 750, 775, 800, 825, 850, 875, 900, 925, 950, 975, 1000, 1025, 1050, 1075, 1100, 1125, 1150, 1175, 1200])
xres=300 ([50, 1200, 1])
yres=300 ([50, 1200, 1])
optical_xres=6400 ([])
optical_yres=6400 ([])
So the question is: how do I override this setting so I am able to scan small areas at 6400dpi?
Again, using the EPSON Scan software I can scan at 6400dpi, provided the scanned area is small.
I know the limit exists for memory reasons, but it doesn't feel right that I can't adjust scan area and resolution, just like the Epson software allows to do.
The problems with using the Epson software is A) I can't automate the process, and B) I can't select an arbitrary scan area in terms of top-left to bottom-right coordinates.
I'm surprised how there is no definite answer on this yet. Let's try to have one once and for all, for posterity!
First of all, beware Pyinsane2 is not maintained anymore. Its replacement is Libinsane. (I'm the author of both).
The maximum of 1200dpi comes of the constraint on xres and yres: xres=300 ([50, 1200, 1]) and yres=300 ([50, 1200, 1]) (resolution is just an alias to those 2 options created by Pyinsane2).
Based on what you say, my guess is that you can get this constraint to go to higher values by setting first the scan area to a smaller one (see tl-x, tl-y, br-x, br-y). However after that, I don't think Pyinsane2 will reload the constraint on resolution correctly and so the max will remain 1200dpi (whereas Libinsane should reload it correctly).
By the way, just to be pedantic, if you have options like dps_optical_xres or optical_xres, you are not using Pyinsane2 on top of Sane (Linux), but Pyinsane2 on top of WIA2 (Windows).
For Linux there is ImageScan v3 with command line option.
I didn't try ImageScan v3 but scanimage (sane) on Ubuntu. 3200 ppi worked without problems.
I'm having some troubles finding the right way how to annotate my data. I'm dealing with laboratory test related texts and I am using the following labels:
1) Test specification (e.g. voltage, length,...)
2) Test object (e.g. battery, steal beam,...)
3) Test value (e.g. 5 V; 5 m...)
Let's take this example sentences:
The battery voltage should be 5 V.
I would annotate this sentences like this:
The
battery voltage (test specification)
should
be
5 V (Test value)
.
However, if this sentences looks like this:
The voltage of the battery should be 5 V.
I would use the following annotation:
The
voltage (Test specification)
of
the
battery (Test object)
should
be
5 V (Test value)
.
Is anyone experienced in annotating data to explain if this is the right way? Or should I use in he first example the Test object label for battery as well? Or should I combine the labels in the second example voltage of the battery as Test specification?
I am annotating the data to perform information extraction.
Thanks for any help!
All of your examples are unusual annotations formats. The typical way to tag NER data (in text) is to use an IOB/BILOU format, where each token is on one line, the file is a TSV, and one of the columns is a label. So for your data it would look like:
The
voltage U-SPEC
of
the
battery U-OBJ
should
be
5 B-VALUE
V L-VALUE
.
Pretend that is TSV, and I have omitted O tags, which are used for "other" items.
You can find documentation of these schema in the spaCy docs.
If you already have data in the format you provided, or you find it easier to make it that way, it should be easy to convert at least. For training NER spaCy requires the data be provided in a particular format, see the docs for details, but basically you need the input text, character spans, and the labels of those spans. Here's example data:
TRAIN_DATA = [
("Who is Shaka Khan?", {"entities": [(7, 17, "PERSON")]}),
("I like London and Berlin.", {"entities": [(7, 13, "LOC"), (18, 24, "LOC")]}),
]
This format is trickier to produce manually than the above TSV type format, so generally you would produce the TSV-like format, possibly using a tool, and then convert it.
The main rule to correctly annotate entities is to be consistent (i.e. you always apply the same rules when deciding which entity is what). I can see you already khave some rules in terms of when battery voltage should be considered test object or test specification.
Apply those rules consistently and you'll be ok.
Have a look at the spacy-annotator.
It is a library that helps you annotating data in the way you want.
Example:
import pandas as pd
import re
from spacy_annotator.pandas_annotations import annotate as pd_annotate
# Data
df = pd.DataFrame.from_dict({'full_text' : [The battery voltage should be 5 V., 'The voltage of the battery should be 5 V.']})
# Annotations
pd_dd = pd_annotate(df,
col_text = 'full_text', # Column in pandas dataframe containing text to be labelled
labels = ['test_specification', 'test object', 'test_value'], # List of labels
sample_size=1, # Size of the sample to be labelled
delimiter=',', # Delimiter to separate entities in GUI
model = None, # spaCy model for noisy pre-labelling
regex_flags=re.IGNORECASE # One (or more) regex flags to be applied when searching for entities in text
)
# Example output
pd_dd['annotations'][0]
The code will show you a user interface you can use to annotate each relevant entities.
I was training spacy name entity recognition with my custom dataset.
One question stick in my mind, why spacy need start and end position of tag in annotation?
[
('I want apples', {'entities': [(2, 5, 'COMMAND'), (7, 12, 'FRUIT')]})
]
Thanks in advance.
Because named entities are allowed to span several tokens, for instance:
("Who is Shaka Khan?", {"entities": [(7, 17, "PERSON")]}),
"Shaka Khan" would be one entity with the label PERSON.
Instead, if you would annotate
("Who is Shaka Khan?", {"entities": [(7, 12, "PERSON")]}),
then only "Shaka" would be the tagged entity.
I am trying to understand how does UWP's Windows.Storage.Streams.DataWriter.WriteDateTime method convert DateTimeOffset values to a byte array. I expected it to work similarly to TimeSpan, where the Ticks are converted to a byte array. Surprisingly, that is not the case.
For example, for DateTimeOffset.MinValue the byte sequence is:
248, 254, 49, 232, 221, 137, 0, 0
And for DateTimeOffset.MaxValue it is:
36, 200, 90, 94, 209, 192, 63, 255
I have tried comparing with output from DateTime.ToBytes() which gives much more reasonable results (e.g. MinValue yields all zeroes).
Can someone suggest or decode which logic is used?
A Windows.Foundation.DateTime is actually an int64 under the covers, representing the number of 100-nanosecond intervals prior to or after midnight on January 1, 1601. It's similar to a Windows FILETIME structure.
The .NET projection converts it to / from the DateTimeOffset structure for you, including any data transforms to the DateTimeOffset representation.
More info is on MSDN
I am learning seaborn from
http://seaborn.pydata.org/tutorial/aesthetics.html
In the import section,please explain this line
np.random.seed(sum(map(ord, "aesthetics")))
What this line does and please explain each element in this line.
In plotting offset sine wave how to define this
plt.plot(x, np.sin(x + i * .5) * (7 - i) * flip)
The importatnt thing first: This line np.random.seed(sum(map(ord, "aesthetics"))) is completely irrelevant for seaborn to work. So in principle you don't have to wory about it at all.
ord gives the byte represenation of a character
map applies a function to every item of an interable
sum sums up the elements of an iterable.
So map(ord, "aesthetics") will give a list of numbers, [97, 101, 115, 116, 104, 101, 116, 105, 99, 115] which when summed up, give 1069.
This number is then fed to np.random.seed. It is a seed for numpy's random number generator. By specifying the seed, you make sure that any random numbers drawn afterwards are based on this seed.
The point of this is to make random numbers reproducible. Having specified the seed allows me to know that when generating a random number like np.random.randint(10) the result will be 4 (for seed 1069).
This is extremely useful to make examples reproducible, and it's the reason they use it in the seaborn tutorial to make sure that the plots generated from random numbers are actually the same everywhere.
One could of course argue that using this command is more confusing than it would confuse people to see different plots when reproducing the tutorial, but that's a different question I guess.