Questions tagged [uint16]

127 questions
1
vote
3 answers

Getting uint16_t value from uint8_t array in Keil

I am trying get variables from UART packet without using "<<" operator. uint8_t buffer[8] = {0x11,0x22,0x33,0x44}; uint16_t val = *((uint16_t *)buffer); If I try the code above in keil it is working. When I try it for the array in struct compiler…
alig24
  • 13
  • 4
1
vote
1 answer

Can't replicate hashing of string

I need to reproduce a JS function that hashes a string with SHA-256 in r. The said function is: function hashPhrase (phrase) { const buf = new ArrayBuffer(phrase.length * 2) const bufView = new Uint16Array(buf) const strLen = phrase.length …
Juan M
  • 119
  • 10
1
vote
1 answer

Wrong access to struct elements in Perl

I am writing a Perl script capable of loading a binary RAW file (.bin file extension), calculate the CRC-16 (unsigned short, 16bits ~ 2 bytes), and store this CRC in a file trailer, using the following commands: my $ctx = Digest::CRC->new( type =>…
1
vote
3 answers

Do I need to use `uint8_t` to do arithmetics on a `uint8_t` pointer?

I have an array of unsigned 8 bit integer, however the length of this array can be higher than 255. I want to use pointer arithmetics instead of array indexing. Can someone explain me if the following code is acceptable or not? My doubt is that the…
JJAlberto
  • 23
  • 5
1
vote
1 answer

Swift convert [UIn16] to UnsafeMutablePointer

I'm trying to convert a UInt16 array to an UnsafeMutablePointer in order to call a C function that takes a uint16_t * from Swift. If my starting point were [UInt8], and my destination UnsafeMutablePointer, it would all be easy. I…
arik
  • 28,170
  • 36
  • 100
  • 156
1
vote
1 answer

How to store into and read back multiple number values on an `uint16_t` using bitwise manipulation?

Using bitwise operations, is it possible to package and read back the following set of values into an uint16_t variable? I think yes but I am trying to figure out how using a sample program. Lets say following is the set of values I want to package…
AdeleGoldberg
  • 1,289
  • 3
  • 12
  • 28
1
vote
1 answer

rendering to the canvas usiing raw UInt16Array values javascript

I'm trying to render an image from a Uint16Array in javascript. I am not getting any caught errors, but nothing is rendering to the canvas. const canvas = document.querySelector('canvas'); const ctx = canvas.getContext('2d'); const…
altruios
  • 986
  • 1
  • 10
  • 29
1
vote
2 answers

Confusion in Rescaling/normalization of uint16 image?

I have 15000 uint images and i have vectorized them to give it as an input to my Convolutional Neural network.[15000x8192] My question is regarding scaling as if i scale like below i get the good result scaler= MinMaxScaler() x_train=…
1
vote
1 answer

Endianness on reinterpret_cast

I have a pointer to an uint8_t aray. Each 2 elements are actually a uint_16_t value and I want to use reinterpret_cast : uint16_t *Dst16Rgb = reinterpret_cast(Dst8Rgb); The output has the wrong endianness, is there a way to specify…
Ivan
  • 1,352
  • 2
  • 13
  • 31
1
vote
0 answers

Keras can't load uint16 tiff images

I have a uint16 tiff image. Keras is not correctly opening the image. All pixel values above 255 seem to be set to 255. When the file is opened with Keras the returned object type is PIL.Image.Image, but when the file is opened with Pillow directly…
user3731622
  • 4,844
  • 8
  • 45
  • 84
1
vote
3 answers

Converting a System.UInt16 array to a string

I'm experiencing a weird issue where I need to remove "blank characters" which are probably not spaces or tabs. It's information from WMI. The "SerialNumberID" property is stored as a UInt16[] Array. I gather it like this : $SERIAL = (Get-WmiObject…
Rakha
  • 1,874
  • 3
  • 26
  • 60
1
vote
1 answer

Fetch Uint16 from readable stream

In the following example I'm fetching 2 raw bytes. fetch('https://www.random.org/cgi-bin/randbyte?nbytes=2') .then(response=>response.body.getReader()) .then(reader=>0/*Here convert to Uint16*/) Any idea how to convert the resulting…
AnArrayOfFunctions
  • 3,452
  • 2
  • 29
  • 66
1
vote
0 answers

How can I convert 2 values from a ByteArray Array to a 16 Bit Integer UInt16 in Swift 4?

Using Xcode 9.4.1 and Swift 4.1 I have a function which reads an Array as Input parameter (see messageData in my Code). Now I want to assign 2 specific Bytes (so 2 values of the ByteArray) to one single UInt16. So I saw the approach with the 0xff in…
leachim
  • 167
  • 4
  • 12
1
vote
0 answers

When using the UINT16 data type. What is difference resize between matlab and opencv?

Looking at the above question, I found why resize results between opencv and matlab are different. However, when the input data type is UINT16, the result is still different. I want to know why this is happening. Resize interpolation :…
raidin
  • 11
  • 2
1
vote
1 answer

numpy array convert uin8 lsb to uint16 msb

I already asked here but I just wonder if this could not be done natively with numpy because I will use numpy later anyway with cv2 that reads numpy arrays. Background is, I read 13 chunks of 13680 bytes from a usb camera until I got 177840 bytes,…
Paul G.
  • 461
  • 6
  • 21
1 2
3
8 9