BinaryReader ReadSingle() - windows-phone-7.1

In my WP7 app, I have used BinaryReader class's ReadSingle() method to read a floating point value from a stream. It works fine and gives the correct value when I run the code on Emulator. But When I run the same code on device, it always gives 0.0 as value. I have no idea why this happens. Please help solve this issue.

Related

FFT in C++ AMP Throw CLIPBRD_E_CANT_OPEN error

I am trying to use C++ AMP in Visual C++ 2017 on Windows 10 (updated to the latest) and I find the archived FFT library from C++ AMP team on codeplex. I try to run the sample code, however the program throws ran out of memory error when creating DirectX FFT. I solve that problem by following the thread on Microsoft forum.
However, the problem doesn't stop. When the FFT library tries to create Unordered Access View, it throws error of CLIPBRD_E_CANT_OPEN. I did not try to operate on clipboard anyhow.
Thank you for reading this!
It seems I solve the problem. The original post mentioned that we need to create a new DirectX device and then create accelerator view upon it. Then I pass that view to ctor of fft as the second parameter.
fft(
concurrency::extent<_Dim> _Transform_extent,
const concurrency::accelerator_view& _Av = concurrency::accelerator().default_view,
float _Forward_scale = 0.0f,
float _Inverse_scale = 0.0f)
However, I still have crashes of the CLIPBRD_E_CANT_OPEN.
After reading the code, I realize that I need to create array on that DirectX views too. So I started to change:
array<std::complex<float>,dims> transformed_array(extend, directx_acc_view);
The idea comes from the different behaviors of create_uav(). The internal buffers and the precomputing caused no problem, but the samples' calls trigger the clipboard error. I guess the device matters here, so I do that change.
I hope my understanding is correct and anyway there is no such errors now.

NativeScript: Get string from interop.reference

To start, here is my code:
var buffer = malloc(interop.sizeof(interop.types.UTF8CString));
var fillBuffer = mac.getBytes(buffer);
var bytes = new interop.Reference(interop.types.UTF8CString, buffer);
var hexMac = bytes[0];
The variable 'Mac' is an NSData objected retrieved from CoreBluetooth. It is the scan response from a BLE device, which contains the peripheral's MAC address (00:0b:57:a2:fb:a0).
This problem is linked to THIS question I had posted earlier.
The solution provided is great; however, I cannot seem to implement this in nativescript :
(instancetype)stringWithFormat:(NSString *)format, ...;
Intellisense tells me the method doesnt exist on type NSString.
Due to that issue, I decided to go another route (as you can tell). I am filling a buffer with the bytes of the MAC address. In the code above, bytes[0] equates to 0xb57a2fba0.
I am now trying to convert that (which is an interop.Reference) into a string that I can store on the back-end (preferably in the xx:xx:xx:xx:xx format).
I have been at this all weekend, and cannot seem to find a solution. I even broke down objc!foundation.d.ts to figure out if stringWithFormat was supported, to no avail.
The nativescript community slack was unable to provide a resolution as well.
Please help if you can!
I don't know anything about NativeScript at all, but given the other code you wrote, I assume you're calling +alloc first, and so mean to use -initWithFormat: (an instance method that initializes) rather than +stringWithFormat: (a class method which handles allocation and initialization).

Using OSVR camera in OpenCV 3

I'm trying to use the OSVR IR camera in OpenCV 3.1.
Initialization works OK.
Green LED is lit on camera.
When I call VideoCapture.read(mat) it returns false and mat is empty.
Other cameras work fine with the same code and VLC can grab the stream from the OSVR camera.
Some further testing reveals: grab() return true, whereas retrieve(mat) again returns false.
Getting width and height from the camera yields expected results but MODE and FORMAT gets me 0.
Is this a config issue? Can it be solved by a combination of VideoCapture.set calls?
Alternative Official answer received from the developers (after my own solution below):
The reason my camera didn't work out of the box with OpenCV might be that it has old firmware (pre-v7).
Work around (or just update firmware):
I found the answer here while browsing anything remotely linked to the issue:
Fastest way to get frames from webcam
You need to specify that it should use DirectShow.
VideoCapture capture( CV_CAP_DSHOW + id_of_camera );

How to convert EDAMTimestamp to NSDate with Evernote Cloud SDK for iOS

I tried Evernote Cloud SDK 2.0.6 for iOS. When I fetch the EDAMSyncChunk and the note data from Evernote service, created (and also updated and deleted) property as NSNumber type in EDAMNote instance has following values for example:
1350039844000
765020000
The former seems to be the UNIX time with milliseconds, so I can convert the value to NSDate object, getting "2012-10-12 20:04:04" (JST).
The latter, however, does not seem to be the correct UNIX time because the value cannot be converted to the acceptable time regardless of removing the last three digits:
765020000 ---> "1994-03-30 18:33:20" (JST)
765020 ---> "1970-01-10 05:30:20" (JST)
How can I get the correct time from the latter case? (I doubt that "765020000" results from something like "xxxx765020000" in 32bit environment, though I cannot check the environment now... sorry)
Please help.
Thanks.
on my project, I got it working like this (in swift):
let date = NSDate(EDAMTimestamp: note.created.longLongValue)

Embedded opencv window in MFC, ERROR

I wrote code to embed opencv window in picture box in MFC. The successful state should be opencv window in the MFC and display pics in MFC. However, my code still make the opencv window flowing around. And I can't find where the problem would be. Any one can help me out?
I will appreciate it.
BOOL SENSEIDlg_XQ::OnInitDialog(){
CDialog::OnInitDialog();
namedWindow("VIDEO",0);
HWND hWnd_video = (HWND)cvGetWindowHandle("VIDEO");
::SetParent(hWnd_video,GetDlgItem(IDC_STATIC_PIC1)->m_hWnd);
HWND video_parent = ::GetParent(hWnd_video);
::ShowWindow(video_parent,SW_HIDE);
return TRUE;
The IDC_STATIC_PIC1 is a picture box in a Cdialog.
I've already figured it out. Write out the solutions for other users who may bump into the same problems. change namedWindow into cvNamedWindow. Apparently, C library is better than C++ here. If you guys bump into the same problem try this.

Resources