Still new to android and java but learning more each day :)
This question refers to
Ok, the error refers to
expression failed to parse:
error: <user expression 27>:1:1: 'bl' has unknown type; cast it to its declared type to use it
bl
^~
and
expression failed to parse:
error: <user expression 28>:1:1: 'uxtb' has unknown type; cast it to its declared type to use it
uxtb.w
^~~~
I call (will want a short ) result = getCheckSum(A, B); from my java code.
The method in my C++ code is
//---------------------------------------------------------------------------
unsigned short ekmCheckCRC16(const unsigned char *dat, unsigned short len)
{
unsigned short crc = 0xffff;
while (len--)
{
crc = (crc >> 8 ) ^ ekmCrcLut[(crc ^ *dat++) & 0xff];
}
crc = (crc << 8 ) | (crc >> 8);
crc &= 0x7f7f;
return crc;
}
//---------------------------------------------------------------------------
// Implementation of the native method getCheckSum()
extern "C"
JNIEXPORT unsigned short JNICALL
Java_com_(...)_getCheckSum(JNIEnv *env, jobject thiz, jstring a) {
const char * aCStr = env->GetStringUTFChars(a, NULL);
if(NULL == aCStr)
return NULL;
unsigned short crc = ekmCheckCRC16(reinterpret_cast<const unsigned char *>(aCStr), strlen(aCStr));
return crc;
}
This code is experimental showing the actual code I want to run ekmCheckCRC16( ... ), its purpose is to learn how to return a value back to the java module.
The error message seems to be clear 'unknown' type cast, so question is, how should I be returning the value of aCStr?
Thanks in advance.
Solved my problem, was simple error of not changing one important detail before executing call i was looking for a return type of short but had String in native declaration.
I had
private native String getCheckSum(String a);
it should have been
`private native short getCheckSum(String a);`
My call was / is
short result = getCheckSum(A);
Worked fine after correcting my mistake.
for those interested my c++ code
#include <jni.h> // JNI header provided by JDK
#include "ekmCheckSum.h"
#include <iostream> // C++ standard IO header
using namespace std;
//---------------------------------------------------------------------------
void ekmCheckSum() {
}
static const unsigned short ekmCrcLut[256] = {
0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241,
0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440,
0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40,
0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841,
0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40,
0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41,
0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641,
0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040,
0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240,
0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441,
0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41,
0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840,
0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41,
0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40,
0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640,
0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041,
0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240,
0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441,
0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41,
0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840,
0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41,
0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40,
0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640,
0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041,
0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241,
0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440,
0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40,
0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841,
0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40,
0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41,
0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641,
0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040
};
//---------------------------------------------------------------------------
unsigned short ekmCheckCRC16(const unsigned char *dat, unsigned short len)
{
unsigned short crc = 0xffff;
while (len--)
{
crc = (crc >> 8 ) ^ ekmCrcLut[(crc ^ *dat++) & 0xff];
}
crc = (crc << 8 ) | (crc >> 8);
crc &= 0x7f7f;
return crc;
}
//---------------------------------------------------------------------------
// Implementation of the native method getCheckSum()
extern "C"
JNIEXPORT unsigned short JNICALL
Java_com_[project name]_ekmV4Fields_getCheckSum(JNIEnv *env, jobject thiz, jstring a) {
const char * aCStr = env->GetStringUTFChars(a, NULL);
if(NULL == aCStr)
return NULL;
unsigned short crc = ekmCheckCRC16(reinterpret_cast<const unsigned char *>(aCStr), strlen(aCStr));
return crc;
}
my .h file contains
#ifndef PROJECT_NAME_EKMCHECKSUM_H
#define PROJECT_NAME_EKMCHECKSUM_H
class ekmCheckSum
{
private:
public:
ekmCheckSum();
unsigned short ekmCheckCRC16(const unsigned char *dat, unsigned short len);
};
#endif //PROJECT_NAME_EKMCHECKSUM_H
my java file includes
static {System.loadLibrary("ekmCheckSum");}
private native short getCheckSum(String a);
public void SetEkmFieldValueStrings(String A, String B)
{
/* if length of A is less than 250 chars, read is no good, discard
* NOTE: both Strings A and B will need to be validated for checksum
* TODO check A & B if checksum is correct
* */
boolean _aOk = false, _bOk=false;
short result = getCheckSum(A);
...
...
I've tried creating a simple jni test app from "Beginning Android Games 3rd Ed" book. I copy-pasted the code, but when I try to link with ndk-build, I get the following error messages:
D:\apps\android\projects\NDK\app\src\main\java>ndk-build
[armeabi-v7a] Compile++ arm : jniutils <= jniutils.cpp
jni/jniutils.cpp:8:52: error: format string is not a string literal (potentially insecure)
[-Werror,-Wformat-security]
__android_log_print(ANDROID_LOG_VERBOSE, cTag, cMessage);
^~~~~~~~
jni/jniutils.cpp:8:52: note: treat the string as an argument to avoid this
__android_log_print(ANDROID_LOG_VERBOSE, cTag, cMessage);
^
"%s",
1 error generated.
make: *** [obj/local/armeabi-v7a/objs/jniutils/jniutils.o] Error 1
If I try to treat these errors as warnings and suppress these with the following lines in android.mk / application.mk:
APP_CFLAGS += -Wno-error=format-security
LOCAL_DISABLE_FORMAT_STRING_CHECKS := true
Then I get this error:
D:\apps\android\projects\NDK\app\src\main\java>ndk-build
[armeabi-v7a] SharedLibrary : libjniutils.so
clang++.exe: error: no such file or directory: '遶上・llog'
make: *** [obj/local/armeabi-v7a/libjniutils.so] Error 1
Which I guess is just some garbage from memory, like a string /variable hasn't been addressed correctly.
I'm very new to jni, so I'm at a bit of a loss of how to troubleshoot this.
Code follows:
JniUtils.java
package com.badlogic.androidgames.ndk;
import java.nio.ByteBuffer;
public class JniUtils {
static {
System.loadLibrary("jniutils");
}
public static native void log(String tag, String message);
public static native void copy(ByteBuffer dst, float[] src, int offset, int len);
}
jniutils.cpp
#include <android/log.h>
#include <string.h>
#include "jniutils.h"
JNIEXPORT void JNICALL Java_com_badlogic_androidgames_ndk_JniUtils_log
(JNIEnv *env, jclass clazz, jstring tag, jstring message) {
const char *cTag = env-> GetStringUTFChars(tag, 0);
const char *cMessage = env-> GetStringUTFChars(message, 0);
__android_log_print(ANDROID_LOG_VERBOSE, cTag, cMessage);
env-> ReleaseStringUTFChars(tag, cTag);
env-> ReleaseStringUTFChars(message, cMessage);
}
JNIEXPORT void JNICALL Java_com_badlogic_androidgames_ndk_JniUtils_copy
(JNIEnv *env, jclass clazz, jobject dst, jfloatArray src, jint offset, jint len) {
unsigned char* pDst = (unsigned char*)env-> GetDirectBufferAddress(dst);
float* pSrc = (float*)env-> GetPrimitiveArrayCritical(src, 0); memcpy(pDst,
pSrc + offset, len * 4);
env-> ReleasePrimitiveArrayCritical(src, pSrc, 0);
}
application.mk
APP_ABI := armeabi-v7a x86
APP_PLATFORM := android-19
android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := jniutils
LOCAL_LDLIBS := − llog
LOCAL_ARM_MODE := arm
LOCAL_SRC_FILES := jniutils.cpp
include $(BUILD_SHARED_LIBRARY)
I am trying to make a proof of concept where in a cpp program I fetch the windows username and then call this program from a java code, using Java native interface(JNI). Now what i have so far is, a sample JNI hello world program which is able to compile and print Hello world or what what ever parameter I set up. Now in a separate cpp snippet i am able to fetch the current username and it works as well; looks as follows:
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
char acUserName[100];
DWORD nUserName = sizeof(acUserName);
if (GetUserName(acUserName, &nUserName)) {
cout << "User name is " << acUserName << "." << endl;
cin.get();
}
return 0;
}
When compiled and executed using my G++ in command prompt it prints the current username correctly.
Now i just want to combine the two programs. When I do that as follows
public class Sample1
{
public native String fetchCurrentUserName();
public static void main(String[] args)
{
System.loadLibrary("Sample1");
Sample1 sample = new Sample1();
String userName = sample.fetchCurrentUserName();
System.out.println("userName: " + userName);
}
}
This is the java part and the cpp part is as follows:
#include "Sample1.h"
#include <string.h>
#include <iostream>
#include <windows.h>
using namespace std;
JNIEXPORT jstring JNICALL Java_Sample1_fetchCurrentUserName
(JNIEnv *env, jobject obj) {
char acUserName[100];
DWORD nUserName = sizeof(acUserName);
if (GetUserName(acUserName, &nUserName)) {
cout << "User name is " << acUserName << "." << endl;
cin.get();
}
const char* userName = acUserName;
//const char* userName = "acUserName";
return env->NewStringUTF(userName);
}
void main(){}
This does not compile anymore, it says
Sample1.obj : error LNK2019: unresolved external symbol __imp_GetUserNameA referenced in function Java_Sample1_fetchCurrentUserName
Sample1.dll : fatal error LNK1120: 1 unresolved externals
I used the following command to compile the JNI code.
cl -I"C:\Program Files\Java\jdk1.8.0_131\include" -I"C:\Program Files\Java\jdk1.8.0_131\include\win32" -LD Sample1.cpp -FeSample1.dll
as per tutorial from https://www.ibm.com/developerworks/java/tutorials/j-jni/j-jni.html. Now from few other questions in stack overflow it seems somehow my program is unable to link the windows library or leader somehow. But I have no clue as to how this can be solved. Any body have any bright ideas? Please make my day! Thank you for your time :D I looked into Linking of dll file in JNI which is very relevant for my question. But not sure if the solutions are applicable to me.
Edit
error: LNK1120: 5 unresolved externals This question had similar problem and it seems to have same solution which is as suggested by Remy to link with Advapi32.lib. At least now i learned few new things like #pragma comments and the role of Advapi32 library. Many thanks!
Your code compiles fine. You are actually getting a linker error, not a compiler error.
From the error message, you can see that your C++ code is trying to call a GetUserNameA() function. GetUserName() is a preprocessor #define macro in winbase.h (which is included by windows.h) that resolves to GetUserNameA() when UNICODE is not defined:
WINADVAPI
BOOL
WINAPI
GetUserNameA (
__out_ecount_part_opt(*pcbBuffer, *pcbBuffer) LPSTR lpBuffer,
__inout LPDWORD pcbBuffer
);
WINADVAPI
BOOL
WINAPI
GetUserNameW (
__out_ecount_part_opt(*pcbBuffer, *pcbBuffer) LPWSTR lpBuffer,
__inout LPDWORD pcbBuffer
);
#ifdef UNICODE
#define GetUserName GetUserNameW
#else
#define GetUserName GetUserNameA // <-- HERE!
#endif // !UNICODE
As there is no GetUserNameA() function implemented in your C++ code, but there is at least a declaration available (from winbase.h), the compiler emits machine code that references GetUserNameA() externally (via a symbol named __imp_GetUserNameA). When the linker is then invoked after compiling is finished, the linker outputs the "unresolved" error because it is not able to find an implementation of any GetUserNameA function to satisfy that reference.
GetUserNameA() is a Win32 API function implemented in Advapi32.dll. You need to link to Advapi32.lib from your compiler's Windows SDK so the linker can find the implementation of GetUserNameA().
One way to do that is to add a #pragma comment(lib) statement to your C++ code, eg:
#include "Sample1.h"
#include <windows.h>
#include <iostream>
using namespace std;
#pragma comment(lib, "Advapi32.lib") // <-- add this!
JNIEXPORT jstring JNICALL Java_Sample1_fetchCurrentUserName(JNIEnv *env, jobject obj) {
char acUserName[100] = {};
DWORD nUserName = sizeof(acUserName);
if (GetUserNameA(acUserName, &nUserName)) {
cout << "User name is " << acUserName << "." << endl;
}
else {
DWORD dwErr = GetLastError();
cout << "Unable to get User name, error " << dwErr << "." << endl;
}
return env->NewStringUTF(acUserName);
}
void main() {}
Alternatively:
#include "Sample1.h"
#include <windows.h>
#include <iostream>
#include <vector>
using namespace std;
#pragma comment(lib, "Advapi32.lib")
JNIEXPORT jstring JNICALL Java_Sample1_fetchCurrentUserName(JNIEnv *env, jobject obj) {
DWORD nUserName = 100, dwErr;
std::vector<char> acUserName(nUserName);
do {
if (GetUserNameA(&acUserName[0], &nUserName)) {
cout << "User name is " << &acUserName[0] << "." << endl;
break;
}
dwErr = GetLastError();
if (dwErr != ERROR_INSUFFICIENT_BUFFER) {
cout << "Unable to get the User name, error " << dwErr << "." << endl;
break;
}
acUserName.resize(nUserName);
}
while (true);
return env->NewStringUTF(&acUserName[0]);
}
void main() {}
That being said, NewStringUTF() requires an input string in modified UTF-8 format. However, GetUserNameA() outputs ANSI format (hence the A in its name), not in UTF-8, let alone modified UTF-8. Windows has no concept of modified UTF-8 at all. Your code will work correctly only if the username does not contain any non-ASCII characters in it.
Your C++ code really should be calling GetUserNameW() instead, which outputs in UTF-16 format. Then you can use NewString() instead of NewStringUTF() (Java strings use UTF-16 anyway), eg:
#include "Sample1.h"
#include <windows.h>
#include <iostream>
using namespace std;
#pragma comment(lib, "Advapi32.lib")
JNIEXPORT jstring JNICALL Java_Sample1_fetchCurrentUserName(JNIEnv *env, jobject obj) {
WCHAR acUserName[100];
DWORD nUserName = 100;
if (GetUserNameW(acUserName, &nUserName)) {
--nUserName; // ignore the null terminator
wcout << L"User name is " << acUserName << L"." << endl;
}
else
{
nUserName = 0;
DWORD dwErr = GetLastError();
cout << "Unable to get the User name, error " << dwErr << "." << endl;
}
return env->NewString(reinterpret_cast<jchar*>(acUserName), nUserName);
}
void main() {}
Alternatively:
#include "Sample1.h"
#include <windows.h>
#include <iostream>
#include <vector>
using namespace std;
#pragma comment(lib, "Advapi32.lib")
JNIEXPORT jstring JNICALL Java_Sample1_fetchCurrentUserName(JNIEnv *env, jobject obj) {
DWORD nUserName = 100, dwErr;
std::vector<WCHAR> acUserName(nUserName);
do {
if (GetUserNameW(&acUserName[0], &nUserName)) {
--nUserName; // ignore the null terminator
wcout << L"User name is " << &acUserName[0] << L"." << endl;
break;
}
dwErr = GetLastError();
if (dwErr != ERROR_INSUFFICIENT_BUFFER) {
nUserName = 0;
cout << "Unable to get the User name, error " << dwErr << "." << endl;
break;
}
acUserName.resize(nUserName);
}
while (true);
return env->NewString(reinterpret_cast<jchar*>(&acUserName[0]), nUserName);
}
void main() {}
I have an opensource shared library called libmbc.so. I am interested in using this library in a java implementation which should be able to reproduce a behavior already tested in c++. Ideally I aim to have access to a class in this library called MBCNodal, and call its member functions in the java wrapper.
If I unroll the content of the shared library with nm -gC libmbc.so, I obtain the following
U __assert_fail##GLIBC_2.2.5
U bind##GLIBC_2.2.5
000000000020e278 B __bss_start
U close##GLIBC_2.2.5
U connect##GLIBC_2.2.5
w __cxa_finalize##GLIBC_2.2.5
U __cxa_pure_virtual##CXXABI_1.3
U __cxa_rethrow##CXXABI_1.3
000000000020e278 D _edata
000000000020e280 B _end
U __errno_location##GLIBC_2.2.5
0000000000009ab0 T _fini
U fprintf##GLIBC_2.2.5
U freeaddrinfo##GLIBC_2.2.5
U free##GLIBC_2.2.5
U fwrite##GLIBC_2.2.5
U getaddrinfo##GLIBC_2.2.5
w __gmon_start__
U __gxx_personality_v0##CXXABI_1.3
0000000000003db8 T _init
w _ITM_deregisterTMCloneTable
w _ITM_registerTMCloneTable
w _Jv_RegisterClasses
U malloc##GLIBC_2.2.5
0000000000004670 T mbc_check_cmd
000000000020e27c B mbc_dummy
00000000000046c0 T mbc_get_cmd
0000000000004850 T mbc_inet_init
0000000000005f60 T mbc_modal_destroy
0000000000005690 T mbc_modal_get_motion
0000000000005a40 T mbc_modal_init
0000000000005b90 T mbc_modal_negotiate_request
0000000000005db0 T mbc_modal_negotiate_response
00000000000058d0 T mbc_modal_put_forces
00000000000055d0 T mbc_nodal_destroy
0000000000004970 T mbc_nodal_get_motion
0000000000004c30 T mbc_nodal_init
00000000000051d0 T mbc_nodal_negotiate_request
00000000000053f0 T mbc_nodal_negotiate_response
0000000000004b30 T mbc_nodal_put_forces
0000000000004720 T mbc_put_cmd
00000000000048f0 T mbc_unix_init
00000000000097a0 T mbdyn_host2inet_addr
0000000000009980 T mbdyn_make_inet_socket
0000000000009890 T mbdyn_make_inet_socket_type
0000000000009aa0 T mbdyn_make_named_socket
00000000000099a0 T mbdyn_make_named_socket_type
U recv##GLIBC_2.2.5
U send##GLIBC_2.2.5
U snprintf##GLIBC_2.2.5
U socket##GLIBC_2.2.5
U stderr##GLIBC_2.2.5
U stdout##GLIBC_2.2.5
U strerror##GLIBC_2.2.5
U strlen##GLIBC_2.2.5
U strncpy##GLIBC_2.2.5
U _Unwind_Resume##GCC_3.0
U usleep##GLIBC_2.2.5
U operator delete(void*, unsigned long)##CXXABI_1.3.9
0000000000006000 T MBCBase::SetTimeout(int)
0000000000006010 T MBCBase::SetVerbose(bool)
0000000000007710 T MBCBase::DynamicsLabel()
0000000000006020 T MBCBase::SetDataAndNext(bool)
0000000000007a20 T MBCBase::F(unsigned char)
0000000000007bf0 T MBCBase::M(unsigned char)
00000000000064b0 T MBCBase::Init(char const*)
0000000000006510 T MBCBase::Init(char const*, unsigned short)
00000000000062b0 T MBCBase::SetStatus(MBCBase::Status)
00000000000063e0 T MBCBase::MBCBase()
00000000000063e0 T MBCBase::MBCBase()
0000000000006490 T MBCBase::~MBCBase()
0000000000006400 T MBCBase::~MBCBase()
0000000000006400 T MBCBase::~MBCBase()
0000000000009310 T MBCModal::Initialize(MBCBase::Rot, unsigned int)
0000000000009490 T MBCModal::DynamicsLabel()
00000000000094b0 T MBCModal::F(unsigned char)
00000000000094d0 T MBCModal::M(unsigned char)
0000000000009730 T MBCModal::P(unsigned int)
00000000000093a0 T MBCModal::MBCModal(MBCBase::Rot, unsigned int)
00000000000092c0 T MBCModal::MBCModal()
00000000000093a0 T MBCModal::MBCModal(MBCBase::Rot, unsigned int)
00000000000092c0 T MBCModal::MBCModal()
0000000000006470 T MBCModal::~MBCModal()
0000000000006450 T MBCModal::~MBCModal()
0000000000006450 T MBCModal::~MBCModal()
0000000000007d40 T MBCNodal::Initialize(MBCBase::Rot, unsigned int, bool, MBCBase::Rot, bool)
0000000000008e60 T MBCNodal::DynamicsLabel(unsigned int)
0000000000007f20 T MBCNodal::DynamicsLabel()
0000000000007f40 T MBCNodal::F(unsigned char)
0000000000009110 T MBCNodal::F(unsigned int, unsigned char)
0000000000007f60 T MBCNodal::M(unsigned char)
0000000000009220 T MBCNodal::M(unsigned int, unsigned char)
0000000000007e00 T MBCNodal::MBCNodal(MBCBase::Rot, unsigned int, bool, MBCBase::Rot, bool)
0000000000007cf0 T MBCNodal::MBCNodal()
0000000000007e00 T MBCNodal::MBCNodal(MBCBase::Rot, unsigned int, bool, MBCBase::Rot, bool)
0000000000007cf0 T MBCNodal::MBCNodal()
0000000000006430 T MBCNodal::~MBCNodal()
0000000000006410 T MBCNodal::~MBCNodal()
0000000000006410 T MBCNodal::~MBCNodal()
00000000000077c0 T MBCBase::GetRefNodeF() const
0000000000007870 T MBCBase::GetRefNodeM() const
0000000000006780 T MBCBase::GetRefNodeR() const
00000000000066d0 T MBCBase::GetRefNodeX() const
0000000000006050 T MBCBase::bDataAndNext() const
0000000000006a20 T MBCBase::GetRefNodeXP() const
0000000000007660 T MBCBase::DynamicsLabel() const
0000000000006100 T MBCBase::GetRefNodeRot() const
0000000000006bb0 T MBCBase::GetRefNodeXPP() const
0000000000006150 T MBCBase::bAccelerations() const
0000000000006ad0 T MBCBase::GetRefNodeOmega() const
0000000000006860 T MBCBase::GetRefNodeTheta() const
0000000000006620 T MBCBase::KinematicsLabel() const
0000000000006c90 T MBCBase::GetRefNodeOmegaP() const
0000000000006940 T MBCBase::GetRefNodeEuler123() const
0000000000007950 T MBCBase::F(unsigned char) const
0000000000007af0 T MBCBase::M(unsigned char) const
0000000000006e60 T MBCBase::R(unsigned char, unsigned char) const
0000000000006d90 T MBCBase::X(unsigned char) const
00000000000075b0 T MBCBase::GetRefNodeDynamicsLabel() const
00000000000065a0 T MBCBase::GetRefNodeKinematicsLabel() const
00000000000071b0 T MBCBase::XP(unsigned char) const
0000000000007380 T MBCBase::XPP(unsigned char) const
0000000000007280 T MBCBase::Omega(unsigned char) const
0000000000006fb0 T MBCBase::Theta(unsigned char) const
0000000000006580 T MBCBase::GetCmd() const
0000000000006080 T MBCBase::GetRot() const
0000000000007480 T MBCBase::OmegaP(unsigned char) const
0000000000006190 T MBCBase::bLabels() const
00000000000060c0 T MBCBase::bRefNode() const
0000000000006030 T MBCBase::bVerbose() const
00000000000070b0 T MBCBase::Euler123(unsigned char) const
0000000000006070 T MBCBase::GetStatus() const
0000000000005fd0 T MBCModal::GetBasePtr() const
0000000000009480 T MBCModal::DynamicsLabel() const
0000000000005fe0 T MBCModal::GetRefNodePtr() const
00000000000093f0 T MBCModal::KinematicsLabel() const
00000000000094a0 T MBCModal::F(unsigned char) const
00000000000094c0 T MBCModal::M(unsigned char) const
00000000000096c0 T MBCModal::P(unsigned int) const
00000000000095a0 T MBCModal::Q(unsigned int) const
0000000000009410 T MBCModal::R(unsigned char, unsigned char) const
0000000000009400 T MBCModal::X(unsigned char) const
0000000000009600 T MBCModal::QP(unsigned int) const
0000000000009440 T MBCModal::XP(unsigned char) const
0000000000009460 T MBCModal::XPP(unsigned char) const
0000000000009670 T MBCModal::GetP() const
0000000000009520 T MBCModal::GetQ() const
00000000000063a0 T MBCModal::Close() const
0000000000009560 T MBCModal::GetQP() const
0000000000009450 T MBCModal::Omega(unsigned char) const
0000000000009420 T MBCModal::Theta(unsigned char) const
0000000000009470 T MBCModal::OmegaP(unsigned char) const
0000000000005ff0 T MBCModal::GetType() const
0000000000009430 T MBCModal::Euler123(unsigned char) const
00000000000094e0 T MBCModal::GetModes() const
0000000000006280 T MBCModal::GetMotion() const
0000000000006350 T MBCModal::Negotiate() const
0000000000006240 T MBCModal::PutForces(bool) const
0000000000005fa0 T MBCNodal::GetBasePtr() const
0000000000008af0 T MBCNodal::GetEuler123(unsigned int) const
0000000000008140 T MBCNodal::GetEuler123() const
0000000000008dd0 T MBCNodal::DynamicsLabel(unsigned int) const
0000000000007f10 T MBCNodal::DynamicsLabel() const
0000000000005fb0 T MBCNodal::GetRefNodePtr() const
0000000000008910 T MBCNodal::KinematicsLabel(unsigned int) const
0000000000007e80 T MBCNodal::KinematicsLabel() const
0000000000008d60 T MBCNodal::GetDynamicsLabel() const
0000000000008880 T MBCNodal::GetKinematicsLabel(unsigned int) const
0000000000007fb0 T MBCNodal::GetKinematicsLabel() const
0000000000007f30 T MBCNodal::F(unsigned char) const
00000000000090a0 T MBCNodal::F(unsigned int, unsigned char) const
0000000000007f50 T MBCNodal::M(unsigned char) const
0000000000009180 T MBCNodal::M(unsigned int, unsigned char) const
0000000000007ea0 T MBCNodal::R(unsigned char, unsigned char) const
00000000000083d0 T MBCNodal::R(unsigned int, unsigned char, unsigned char) const
0000000000007e90 T MBCNodal::X(unsigned char) const
0000000000008360 T MBCNodal::X(unsigned int, unsigned char) const
0000000000007ed0 T MBCNodal::XP(unsigned char) const
0000000000008600 T MBCNodal::XP(unsigned int, unsigned char) const
0000000000007ef0 T MBCNodal::XPP(unsigned char) const
0000000000008710 T MBCNodal::XPP(unsigned int, unsigned char) const
0000000000008fa0 T MBCNodal::GetF(unsigned int) const
0000000000008ef0 T MBCNodal::GetF() const
0000000000009010 T MBCNodal::GetM(unsigned int) const
0000000000008f30 T MBCNodal::GetM() const
00000000000089f0 T MBCNodal::GetR(unsigned int) const
0000000000008060 T MBCNodal::GetR() const
00000000000089a0 T MBCNodal::GetX(unsigned int) const
0000000000008020 T MBCNodal::GetX() const
0000000000006310 T MBCNodal::Close() const
0000000000008b70 T MBCNodal::GetXP(unsigned int) const
00000000000081b0 T MBCNodal::GetXP() const
0000000000007ee0 T MBCNodal::Omega(unsigned char) const
0000000000008670 T MBCNodal::Omega(unsigned int, unsigned char) const
0000000000007eb0 T MBCNodal::Theta(unsigned char) const
00000000000084a0 T MBCNodal::Theta(unsigned int, unsigned char) const
0000000000008c40 T MBCNodal::GetXPP(unsigned int) const
0000000000008260 T MBCNodal::GetXPP() const
0000000000007f00 T MBCNodal::OmegaP(unsigned char) const
00000000000087b0 T MBCNodal::OmegaP(unsigned int, unsigned char) const
0000000000005fc0 T MBCNodal::GetType() const
0000000000007ec0 T MBCNodal::Euler123(unsigned char) const
0000000000008550 T MBCNodal::Euler123(unsigned int, unsigned char) const
0000000000007f70 T MBCNodal::GetNodes() const
0000000000008bc0 T MBCNodal::GetOmega(unsigned int) const
00000000000081f0 T MBCNodal::GetOmega() const
0000000000008a70 T MBCNodal::GetTheta(unsigned int) const
00000000000080d0 T MBCNodal::GetTheta() const
0000000000006210 T MBCNodal::GetMotion() const
0000000000008cc0 T MBCNodal::GetOmegaP(unsigned int) const
00000000000082d0 T MBCNodal::GetOmegaP() const
00000000000062c0 T MBCNodal::Negotiate() const
00000000000061d0 T MBCNodal::PutForces(bool) const
000000000020dc48 V typeinfo for MBCBase
000000000020dc70 V typeinfo for MBCModal
000000000020dc58 V typeinfo for MBCNodal
000000000000b468 V typeinfo name for MBCBase
000000000000b488 V typeinfo name for MBCModal
000000000000b478 V typeinfo name for MBCNodal
000000000020dc88 V vtable for MBCBase
000000000020dd38 V vtable for MBCModal
000000000020dce0 V vtable for MBCNodal
U vtable for __cxxabiv1::__class_type_info##CXXABI_1.3
U vtable for __cxxabiv1::__si_class_type_info##CXXABI_1.3
Therefore I have the feeling that the MBCNodal class is somehow accessible with JNA. But I don't manage to figure out how?
I wish not to modify the library implementation. I have the source code of both .h and .cpp. But I don't know how it was compiled in order to produce the libmbc.so.
thanks for your help.
Edit:
here is a sample code on how I load the library and access the extern methods:
private interface Wrapper extends Library {
Wrapper INSTANCE = Native.loadLibrary( C_LIBRARY_PATH, Wrapper.class );
Pointer mbc_nodal_init(Pointer ptr, int refnode, int nodes, int label, int rot, int accels);
int mbc_nodal_get_motion(Pointer ptr);
int mbc_nodal_negotiate_request(Pointer ptr);
int mbc_nodal_put_forces(Pointer ptr, int converged);
}
You can use JNI as an adapter.
Take a look at these two samples. I guess, this is something you are looking for.
http://jnicookbook.owsiak.org/recipe-No-021/
http://jnicookbook.owsiak.org/recipe-No-023/
In both cases, you have code that will be adapted by JNI code
Of course, you have to make sure to properly map Java data to what ever is required in your .so based functions.
As for the JNA, there is quite comprehensive tutorial site here:
http://www.eshayne.com/jnaex/index.html
I have a problem for parsing float from char in JNI-Android Application.This char is a like data vector<float> from custom HOG https://github.com/DaHoC/trainHOG/wiki/trainHOG-Tutorial. I want to detect my custom HOG Animal. So this is one sample chars for +1 (Positive Image) from 49 data.
+1 1:0.0516209 2:0.0526671 3:0.0621273 4:0.162602 5:0.252267 6:0.220246 7:0.116933 8:0.0665012 9:0.040535 10:0.0810178 11:0.0799648 12:0.0989393 13:0.204468 14:0.252267 15:0.232619 16:0.10104 17:0.0503855 18:0.0872255 19:0.109535 20:0.135352 21:0.252267 22:0.252267 23:0.252267 24:0.19159 25:0.139957 26:0.0849861 27:0.0621954 28:0.180085 29:0.220934 30:0.252267 31:0.252267 32:0.252267 33:0.14686 34:0.133376 35:0.0798698 36:0.143804 37:0.154667 38:0.175837 39:0.175819 40:0.185156 41:0.242682 42:0.143323 43:0.0656771 44:0.0752698 45:0.120002 46:0.125042 47:0.137929 48:0.141668 49:0.238362 50:0.242682 51:0.187268 52:0.0587663 53:0.0820198 54:0.0561508 55:0.173739 56:0.235661 57:0.176866 58:0.242682 59:0.242682 60:0.120697 61:0.0926801 62:0.074838 63:0.120294 64:0.099418 65:0.165938 66:0.223667 67:0.242682 68:0.242682 69:0.242682 70:0.0941423 71:0.0576666 72:0.0232888 73:0.030905 74:0.0741619 75:0.128762 76:0.241179 77:0.284917 78:0.284917 79:0.0878371 80:0.057604 81:0.0254226 82:0.0749189 83:0.0660299 84:0.112901 85:0.165158 86:0.284917 87:0.205528 88:0.0918434 89:0.0600073 90:0.0772874 91:0.0374085 92:0.119716 93:0.183876 94:0.237916 95:0.284917 96:0.284917 97:0.11597 98:0.0431861 99:0.0226412 100:0.053028 101:0.0779262 102:0.138294 103:0.197107 104:0.284917 105:0.284917 106:0.155058 107:0.09058 108:0.0685508 109:0.107512 110:0.0580869 111:0.155158 112:0.243893 113:0.215341 114:0.129598 115:0.048822 116:0.0425757 117:0.0809534 118:0.1627 119:0.124774 120:0.198517 121:0.259591 122:0.259591 123:0.109071 124:0.0437223 125:0.0560505 126:0.0753148 127:0.0582958 128:0.0646337 129:0.207277 130:0.259591 131:0.248938 132:0.259591 133:0.135874 134:0.113958 135:0.061379 136:0.0877517 137:0.115159 138:0.223133 139:0.259591 140:0.259591 141:0.259591 142:0.135361 143:0.0905518 144:0.0649403 145:0.104641 146:0.139505 147:0.234039 148:0.234039 149:0.209601 150:0.213197 151:0.132382 152:0.0932568 153:0.0901358 154:0.185335 155:0.232361 156:0.234039 157:0.234039 158:0.154098 159:0.167337 160:0.179891 161:0.118966 162:0.131475 163:0.0564679 164:0.105363 165:0.167412 166:0.231988 167:0.228415 168:0.228708 169:0.104494 170:0.072458 171:0.0586462 172:0.0992585 173:0.117884 174:0.104316 175:0.151379 176:0.187837 177:0.156796 178:0.232444 179:0.139886 180:0.0964207 181:0.145255 182:0.198792 183:0.150749 184:0.221525 185:0.19881 186:0.178096 187:0.226074 188:0.121964 189:0.102861 190:0.0437534 191:0.131493 192:0.178541 193:0.21926 194:0.234759 195:0.254669 196:0.157603 197:0.0723847 198:0.0244493 199:0.065348 200:0.0853451 201:0.0624319 202:0.103251 203:0.139865 204:0.220055 205:0.254669 206:0.223438 207:0.0848672 208:0.0425032 209:0.0791857 210:0.138352 211:0.157657 212:0.200656 213:0.254669 214:0.254669 215:0.167132 216:0.0369475 217:0.0398139 218:0.124495 219:0.180236 220:0.185851 221:0.262945 222:0.262945 223:0.142996 224:0.09139 225:0.0423195 226:0.0673232 227:0.067754 228:0.118807 229:0.177049 230:0.217177 231:0.262945 232:0.206083 233:0.154343 234:0.129637 235:0.071941 236:0.0843471 237:0.154425 238:0.167051 239:0.223171 240:0.262945 241:0.230233 242:0.168113 243:0.0707214 244:0.0988057 245:0.110709 246:0.10464 247:0.170808 248:0.142613 249:0.198069 250:0.193661 251:0.206063 252:0.139514 253:0.070888 254:0.0546235 255:0.0987665 256:0.179403 257:0.176451 258:0.231507 259:0.170609 260:0.170777 261:0.134404 262:0.0957243 263:0.0741578 264:0.113292 265:0.210238 266:0.215958 267:0.264889 268:0.175568 269:0.120427 270:0.0934888 271:0.107025 272:0.127747 273:0.0658595 274:0.172265 275:0.187371 276:0.264889 277:0.179685 278:0.217699 279:0.124863 280:0.140482 281:0.0842961 282:0.0816219 283:0.186152 284:0.26147 285:0.264889 286:0.14057 287:0.18035 288:0.149876 289:0.0789043 290:0.170528 291:0.259454 292:0.244211 293:0.259454 294:0.255461 295:0.124829 296:0.0738446 297:0.0424127 298:0.197806 299:0.162143 300:0.144715 301:0.122082 302:0.171563 303:0.123079 304:0.188536 305:0.128817 306:0.0890725 307:0.0940822 308:0.185499 309:0.259454 310:0.252905 311:0.211187 312:0.161549 313:0.115569 314:0.0730725 315:0.0770362 316:0.226353 317:0.181456 318:0.223296 319:0.170029 320:0.117185 321:0.0981806 322:0.0746445 323:0.060523 324:0.0916957 325:0.0950073 326:0.0789168 327:0.0433256 328:0.0477858 329:0.109855 330:0.13269 331:0.207804 332:0.182029 333:0.0941013 334:0.118187 335:0.0871392 336:0.0667544 337:0.125589 338:0.256858 339:0.254672 340:0.256858 341:0.219227 342:0.102974 343:0.160436 344:0.140071 345:0.0956094 346:0.0954186 347:0.105212 348:0.0769432 349:0.134467 350:0.104214 351:0.153261 352:0.236158 353:0.218971 354:0.134611 355:0.232192 356:0.256858 357:0.160758 358:0.229581 359:0.215932 360:0.256858 361:0.131302 362:0.0838311 363:0.0680505 364:0.0964724 365:0.167542 366:0.163733 367:0.159702 368:0.11763 369:0.0803405 370:0.147074 371:0.153463 372:0.141674 373:0.108444 374:0.110367 375:0.155245 376:0.0968434 377:0.0853039 378:0.0769986 379:0.233289 380:0.184741 381:0.148944 382:0.195778 383:0.249193 384:0.148996 385:0.183793 386:0.157546 387:0.249193 388:0.249193 389:0.249193 390:0.249193 391:0.16308 392:0.180707 393:0.154442 394:0.126717 395:0.145393 396:0.249193 397:0.0897672 398:0.14826 399:0.16095 400:0.191101 401:0.183119 402:0.242813 403:0.0559302 404:0.0604032 405:0.0441353 406:0.0892086 407:0.0911337 408:0.0933983 409:0.204716 410:0.249644 411:0.24499 412:0.0836525 413:0.0743139 414:0.0867809 415:0.230095 416:0.209791 417:0.249644 418:0.249644 419:0.203505 420:0.169885 421:0.0601984 422:0.0619023 423:0.149432 424:0.095661 425:0.119704 426:0.185102 427:0.249644 428:0.249644 429:0.2331 430:0.172669 431:0.0571165 432:0.0554624 433:0.105544 434:0.124474 435:0.204209 436:0.149226 437:0.287671 438:0.233312 439:0.158538 440:0.085772 441:0.102165 442:0.117022 443:0.122671 444:0.160237 445:0.151971 446:0.143499 447:0.129942 448:0.0959389 449:0.0556028 450:0.0864025 451:0.167466 452:0.0568043 453:0.105169 454:0.28099 455:0.287671 456:0.287671 457:0.203573 458:0.0838686 459:0.125802 460:0.19001 461:0.0978778 462:0.118772 463:0.103927 464:0.206477 465:0.221949 466:0.147634 467:0.109453 468:0.21046 469:0.0934628 470:0.111775 471:0.0854255 472:0.0896416 473:0.0980298 474:0.0729928 475:0.101601 476:0.0468797 477:0.0791986 478:0.158492 479:0.162197 480:0.188256 481:0.310893 482:0.298819 483:0.152905 484:0.154461 485:0.104955 486:0.219529 487:0.105981 488:0.109796 489:0.0943929 490:0.116314 491:0.211338 492:0.183864 493:0.15099 494:0.0466525 495:0.0814759 496:0.0826441 497:0.133331 498:0.189644 499:0.310893 500:0.310893 501:0.310893 502:0.178649 503:0.0622459 504:0.0721505 505:0.161893 506:0.112677 507:0.17197 508:0.261516 509:0.231606 510:0.12838 511:0.119647 512:0.0897209 513:0.204429 514:0.258437 515:0.151017 516:0.232684 517:0.106046 518:0.119519 519:0.118933 520:0.102533 521:0.109681 522:0.261516 523:0.0781687 524:0.0865439 525:0.120502 526:0.261516 527:0.261516 528:0.261516 529:0.0982907 530:0.0651658 531:0.0631546 532:0.205084 533:0.151398 534:0.215174 535:0.0894046 536:0.133384 537:0.157612 538:0.100458 539:0.0809739 540:0.148817 541:0.239039 542:0.163965 543:0.24837 544:0.147138 545:0.137003 546:0.198188 547:0.0955781 548:0.0704638 549:0.201737 550:0.09251 551:0.13307 552:0.203236 553:0.230284 554:0.24581 555:0.24837 556:0.163676 557:0.0441309 558:0.05486 559:0.200242 560:0.18874 561:0.24837 562:0.122286 563:0.111089 564:0.170059 565:0.0974838 566:0.0557162 567:0.139893 568:0.142029 569:0.135066 570:0.239535 571:0.165015 572:0.151529 573:0.215339 574:0.109499 575:0.0477798 576:0.102104 577:0.142869 578:0.0506508 579:0.099281 580:0.311296 581:0.311296 582:0.29235 583:0.0853785 584:0.0298867 585:0.0839334 586:0.217339 587:0.102943 588:0.0936696 589:0.0937782 590:0.148731 591:0.120643 592:0.0644866 593:0.105494 594:0.223154 595:0.124304 596:0.0630043 597:0.0882641 598:0.290856 599:0.311296 600:0.311296 601:0.159524 602:0.0136488 603:0.0657668 604:0.204307 605:0.149414 606:0.111302 607:0.106827 608:0.11079 609:0.117657 610:0.0400945 611:0.0877738 612:0.183063 613:0.133036 614:0.11257 615:0.114527 616:0.079359 617:0.144871 618:0.166868 619:0.0980467 620:0.0701586 621:0.136393 622:0.144127 623:0.204131 624:0.184349 625:0.273352 626:0.273352 627:0.273352 628:0.117483 629:0.0403787 630:0.101049 631:0.154879 632:0.180959 633:0.167622 634:0.138856 635:0.0361039 636:0.0806388 637:0.0373684 638:0.0916881 639:0.156742 640:0.223871 641:0.273352 642:0.271826 643:0.273352 644:0.165789 645:0.124406 646:0.0731598 647:0.143914 648:0.174675 649:0.112238 650:0.164751 651:0.0874189 652:0.161027 653:0.280177 654:0.223749 655:0.0456342 656:0.0362706 657:0.0407592 658:0.236262 659:0.280177 660:0.280177 661:0.0951557 662:0.137062 663:0.0833213 664:0.0380415 665:0.0730444 666:0.0742162 667:0.173875 668:0.280177 669:0.210483 670:0.195704 671:0.156123 672:0.0756225 673:0.0553245 674:0.106288 675:0.11255 676:0.231428 677:0.280177 678:0.280177 679:0.132035 680:0.0793173 681:0.0650503 682:0.0857836 683:0.126709 684:0.141397 685:0.215868 686:0.298669 687:0.298669 688:0.208136 689:0.0907796 690:0.0632681 691:0.0523893 692:0.0769242 693:0.0955798 694:0.0874953 695:0.098873 696:0.244548 697:0.186292 698:0.111636 699:0.105521 700:0.0849176 701:0.0982519 702:0.0771137 703:0.180454 704:0.298669 705:0.298669 706:0.255643 707:0.0955855 708:0.0588408 709:0.0775926 710:0.161626 711:0.132766 712:0.078477 713:0.0844616 714:0.298669 715:0.242583 716:0.107347 717:0.0798445 718:0.0853468 719:0.103689 720:0.065806 721:0.0357221 722:0.0298848 723:0.0814559 724:0.167687 725:0.266033 726:0.266033 727:0.250278 728:0.0899015 729:0.0693378 730:0.074513 731:0.0717591 732:0.120642 733:0.0856944 734:0.0741726 735:0.111318 736:0.0733351 737:0.111474 738:0.102383 739:0.0333341 740:0.0476535 741:0.090083 742:0.119321 743:0.266033 744:0.266033 745:0.266033 746:0.266033 747:0.186286 748:0.126744 749:0.0692135 750:0.161342 751:0.110722 752:0.266033 753:0.180974 754:0.180172 755:0.266033 756:0.23479 757:0.117383 758:0.159488 759:0.246485 760:0.240844 761:0.0489906 762:0.0327636 763:0.0302243 764:0.0614286 765:0.0963371 766:0.174301 767:0.246485 768:0.246485 769:0.246485 770:0.0998213 771:0.0707082 772:0.0477948 773:0.138016 774:0.121114 775:0.204169 776:0.113 777:0.246485 778:0.220392 779:0.246485 780:0.113499 781:0.046402 782:0.0894608 783:0.168363 784:0.192057 785:0.17405 786:0.246485 787:0.221395 788:0.227333 789:0.139138 790:0.0606163 791:0.0669251 792:0.162615 793:0.168169 794:0.264854 795:0.243766 796:0.140564 797:0.0976328 798:0.0677347 799:0.0445176 800:0.15511 801:0.15869 802:0.264854 803:0.264854 804:0.246155 805:0.104299 806:0.0436364 807:0.0780234 808:0.131923 809:0.166165 810:0.2136 811:0.132863 812:0.238265 813:0.157387 814:0.103066 815:0.151245 816:0.096932 817:0.0574446 818:0.107677 819:0.132774 820:0.238755 821:0.264854 822:0.112574 823:0.141528 824:0.182357 825:0.106048 826:0.12458 827:0.150181 828:0.164209 829:0.24785 830:0.24785 831:0.24785 832:0.191579 833:0.0602815 834:0.0766117 835:0.118639 836:0.180041 837:0.177137 838:0.0915748 839:0.10766 840:0.24785 841:0.199659 842:0.0899677 843:0.130194 844:0.105077 845:0.0814451 846:0.0724681 847:0.220688 848:0.24785 849:0.145892 850:0.207808 851:0.151263 852:0.0936182 853:0.13452 854:0.151408 855:0.202105 856:0.107693 857:0.143771 858:0.233332 859:0.201684 860:0.184008 861:0.147185 862:0.120236 863:0.101269 864:0.155512
This is a one sample data char for -1 (Negative Image) from 22 data
-1 1:0.202916 2:0.238127 3:0.128888 4:0.137708 5:0.155601 6:0.105077 7:0.0983977 8:0.0843581 9:0.10491 10:0.238127 11:0.193283 12:0.115676 13:0.0532577 14:0.128305 15:0.112788 16:0.1271 17:0.143537 18:0.18471 19:0.142134 20:0.238127 21:0.139083 22:0.118682 23:0.238127 24:0.202205 25:0.147178 26:0.216429 27:0.0681436 28:0.20095 29:0.238127 30:0.196387 31:0.0990107 32:0.184812 33:0.178951 34:0.191704 35:0.230855 36:0.0895278 37:0.244468 38:0.15381 39:0.102552 40:0.0984278 41:0.227776 42:0.15434 43:0.0989782 44:0.19254 45:0.244468 46:0.0932954 47:0.0564859 48:0.0652223 49:0.193186 50:0.244468 51:0.195653 52:0.0678904 53:0.075226 54:0.0637843 55:0.240463 56:0.223208 57:0.189486 58:0.140949 59:0.148009 60:0.166039 61:0.198906 62:0.231404 63:0.142599 64:0.112919 65:0.104909 66:0.168501 67:0.244468 68:0.244468 69:0.135938 70:0.119736 71:0.0904195 72:0.082083 73:0.0307629 74:0.0312645 75:0.0487461 76:0.261841 77:0.282171 78:0.213438 79:0.0536121 80:0.0518256 81:0.0342206 82:0.0217149 83:0.0546434 84:0.0925523 85:0.244762 86:0.282171 87:0.282171 88:0.0968079 89:0.0927951 90:0.0540228 91:0.0481936 92:0.0557246 93:0.160169 94:0.282171 95:0.282171 96:0.24888 97:0.0563694 98:0.0597031 99:0.0795414 100:0.0643808 101:0.0684838 102:0.101178 103:0.282171 104:0.282171 105:0.282171 106:0.0793248 107:0.0722633 108:0.0745563 109:0.0101671 110:0.0276036 111:0.127687 112:0.262004 113:0.275387 114:0.245632 115:0.0609076 116:0.0512514 117:0.028738 118:0.0580375 119:0.0282748 120:0.211778 121:0.275387 122:0.275387 123:0.240033 124:0.0521407 125:0.0386775 126:0.0494758 127:0.0480672 128:0.0498178 129:0.126303 130:0.213497 131:0.275387 132:0.259392 133:0.0623863 134:0.0584124 135:0.0302611 136:0.0335715 137:0.0208229 138:0.183583 139:0.265358 140:0.275387 141:0.275387 142:0.1205 143:0.0981494 144:0.0628459 145:0.109558 146:0.177318 147:0.0987865 148:0.0929232 149:0.21123 150:0.154632 151:0.107868 152:0.214756 153:0.108362 154:0.0714979 155:0.209598 156:0.149005 157:0.171135 158:0.219599 159:0.19332 160:0.157791 161:0.219599 162:0.0952607 163:0.131616 164:0.21878 165:0.190347 166:0.103918 167:0.109131 168:0.0903577 169:0.0757711 170:0.137984 171:0.219599 172:0.114108 173:0.219599 174:0.213487 175:0.206846 176:0.219599 177:0.172328 178:0.129206 179:0.178524 180:0.219599 181:0.0577419 182:0.155792 183:0.123421 184:0.176922 185:0.230393 186:0.203766 187:0.230393 188:0.22723 189:0.0913815 190:0.0649546 191:0.0973571 192:0.168345 193:0.230393 194:0.170253 195:0.118387 196:0.165572 197:0.113887 198:0.0749892 199:0.0396387 200:0.123303 201:0.158325 202:0.230393 203:0.230393 204:0.230393 205:0.204921 206:0.175129 207:0.125109 208:0.035194 209:0.0551479 210:0.148492 211:0.230393 212:0.230393 213:0.223908 214:0.155903 215:0.161129 216:0.0972978 217:0.0636359 218:0.0474713 219:0.175701 220:0.2591 221:0.2591 222:0.160876 223:0.0781598 224:0.0768989 225:0.0748914 226:0.10912 227:0.0519005 228:0.114402 229:0.24724 230:0.2591 231:0.25836 232:0.0837505 233:0.0631729 234:0.0720033 235:0.0555216 236:0.0236018 237:0.10125 238:0.2591 239:0.2591 240:0.219502 241:0.241907 242:0.163548 243:0.0839565 244:0.0881268 245:0.0503224 246:0.0498073 247:0.216185 248:0.2591 249:0.2591 250:0.214226 251:0.0926044 252:0.0816564 253:0.112619 254:0.0605715 255:0.141974 256:0.214129 257:0.257826 258:0.217006 259:0.0719633 260:0.0620509 261:0.0397661 262:0.0786594 263:0.063506 264:0.184286 265:0.236293 266:0.257826 267:0.257826 268:0.153774 269:0.118041 270:0.0951895 271:0.124074 272:0.0842194 273:0.094113 274:0.160672 275:0.257826 276:0.257826 277:0.111546 278:0.0530195 279:0.0554362 280:0.104514 281:0.123719 282:0.257826 283:0.230009 284:0.257826 285:0.220973 286:0.140466 287:0.0902431 288:0.118578 289:0.13191 290:0.176977 291:0.234451 292:0.132086 293:0.0673623 294:0.0843796 295:0.132341 296:0.1946 297:0.206191 298:0.125072 299:0.192002 300:0.234451 301:0.234451 302:0.148904 303:0.120588 304:0.114092 305:0.163777 306:0.175541 307:0.101147 308:0.125462 309:0.164906 310:0.162793 311:0.134718 312:0.133301 313:0.234451 314:0.234451 315:0.128525 316:0.110798 317:0.0944765 318:0.218814 319:0.234451 320:0.201594 321:0.12267 322:0.213044 323:0.146956 324:0.0916341 325:0.0467531 326:0.0979971 327:0.179889 328:0.261865 329:0.18782 330:0.18751 331:0.122321 332:0.0982152 333:0.0896316 334:0.0292257 335:0.0284248 336:0.137201 337:0.261865 338:0.261865 339:0.261865 340:0.194944 341:0.0918262 342:0.0595214 343:0.0591814 344:0.0803219 345:0.208379 346:0.254768 347:0.166724 348:0.123515 349:0.186031 350:0.110829 351:0.0965476 352:0.0371847 353:0.0504509 354:0.154525 355:0.206632 356:0.261865 357:0.261865 358:0.261865 359:0.0722217 360:0.0800643 361:0.0409688 362:0.0176752 363:0.0569232 364:0.283295 365:0.283295 366:0.259439 367:0.283295 368:0.105985 369:0.0497671 370:0.0789917 371:0.0362733 372:0.0236163 373:0.146088 374:0.232727 375:0.210617 376:0.206419 377:0.0691863 378:0.0658879 379:0.0402945 380:0.0286892 381:0.0559084 382:0.191715 383:0.283295 384:0.283295 385:0.283295 386:0.0868175 387:0.0366786 388:0.110066 389:0.0266581 390:0.0233228 391:0.119706 392:0.252106 393:0.242942 394:0.190844 395:0.064017 396:0.0875403 397:0.166629 398:0.0899554 399:0.0677852 400:0.119023 401:0.250455 402:0.223322 403:0.184076 404:0.0784621 405:0.0816593 406:0.110259 407:0.139618 408:0.250455 409:0.151872 410:0.250455 411:0.187937 412:0.217633 413:0.127164 414:0.113712 415:0.189946 416:0.0618852 417:0.0649265 418:0.150097 419:0.218379 420:0.155659 421:0.155087 422:0.0815997 423:0.143141 424:0.122289 425:0.102314 426:0.250455 427:0.220619 428:0.250455 429:0.151841 430:0.169793 431:0.135818 432:0.178764 433:0.162701 434:0.102889 435:0.0567895 436:0.129393 437:0.149302 438:0.177379 439:0.239908 440:0.169264 441:0.149341 442:0.0779376 443:0.0355276 444:0.113565 445:0.245542 446:0.184525 447:0.159865 448:0.177483 449:0.0998318 450:0.0939305 451:0.213265 452:0.15501 453:0.117276 454:0.196975 455:0.245542 456:0.245542 457:0.181286 458:0.122424 459:0.178347 460:0.0853598 461:0.0776414 462:0.123375 463:0.245542 464:0.245542 465:0.245542 466:0.12568 467:0.124069 468:0.157908 469:0.0483786 470:0.0488987 471:0.133479 472:0.20808 473:0.132927 474:0.0863621 475:0.143265 476:0.0962188 477:0.0682617 478:0.0375666 479:0.0391207 480:0.0866582 481:0.165039 482:0.255371 483:0.255371 484:0.243334 485:0.0814715 486:0.0753955 487:0.0936942 488:0.129051 489:0.1357 490:0.24164 491:0.255371 492:0.153412 493:0.174077 494:0.255371 495:0.103484 496:0.111238 497:0.0902079 498:0.0954442 499:0.255371 500:0.255371 501:0.255371 502:0.203751 503:0.237107 504:0.110315 505:0.0526282 506:0.0322868 507:0.0423939 508:0.184663 509:0.297181 510:0.297181 511:0.251596 512:0.106993 513:0.0522684 514:0.0625633 515:0.0295701 516:0.0552298 517:0.159044 518:0.258566 519:0.201533 520:0.100106 521:0.0897315 522:0.0890958 523:0.0922364 524:0.0613719 525:0.0807405 526:0.297181 527:0.297181 528:0.297181 529:0.138955 530:0.151343 531:0.125865 532:0.0558962 533:0.0610004 534:0.12525 535:0.196676 536:0.238344 537:0.214618 538:0.0837075 539:0.112279 540:0.105342 541:0.0982794 542:0.0411905 543:0.0932071 544:0.197392 545:0.235027 546:0.128419 547:0.0539251 548:0.0599048 549:0.121678 550:0.151401 551:0.0705359 552:0.205576 553:0.260876 554:0.264424 555:0.21007 556:0.0857578 557:0.0984105 558:0.177422 559:0.124249 560:0.0727931 561:0.151987 562:0.248837 563:0.241573 564:0.157753 565:0.0715951 566:0.0821431 567:0.129323 568:0.211749 569:0.101268 570:0.124817 571:0.264424 572:0.264424 573:0.264424 574:0.0945323 575:0.0944857 576:0.169243 577:0.0977583 578:0.0973214 579:0.090172 580:0.14533 581:0.258168 582:0.219136 583:0.211844 584:0.182759 585:0.0851776 586:0.0491024 587:0.10393 588:0.097326 589:0.215013 590:0.258168 591:0.24219 592:0.114956 593:0.144647 594:0.147168 595:0.0887443 596:0.0919797 597:0.0948256 598:0.129122 599:0.206411 600:0.170214 601:0.196858 602:0.155078 603:0.131503 604:0.0524837 605:0.121219 606:0.176196 607:0.228174 608:0.258168 609:0.204058 610:0.132163 611:0.169165 612:0.224304 613:0.0874906 614:0.146734 615:0.0862 616:0.170733 617:0.228861 618:0.152198 619:0.150799 620:0.228861 621:0.165516 622:0.104408 623:0.136736 624:0.0724613 625:0.195694 626:0.228861 627:0.134728 628:0.138115 629:0.228861 630:0.104284 631:0.0729019 632:0.123573 633:0.200347 634:0.205191 635:0.228861 636:0.185752 637:0.120049 638:0.19879 639:0.228861 640:0.0772772 641:0.110958 642:0.0920094 643:0.142821 644:0.201881 645:0.195723 646:0.134162 647:0.228861 648:0.187852 649:0.0736535 650:0.112542 651:0.12742 652:0.247577 653:0.247577 654:0.205901 655:0.107634 656:0.135854 657:0.0954487 658:0.0599283 659:0.0793993 660:0.173128 661:0.225048 662:0.205814 663:0.19194 664:0.101191 665:0.073265 666:0.0790001 667:0.0507331 668:0.104515 669:0.130859 670:0.238863 671:0.247577 672:0.238513 673:0.186152 674:0.217666 675:0.115738 676:0.0912129 677:0.106256 678:0.213899 679:0.219618 680:0.216841 681:0.223208 682:0.203846 683:0.0998502 684:0.0652137 685:0.119432 686:0.07891 687:0.147334 688:0.203575 689:0.185982 690:0.171594 691:0.104885 692:0.0709552 693:0.108609 694:0.137597 695:0.0881497 696:0.105485 697:0.256408 698:0.256408 699:0.256408 700:0.133865 701:0.0892009 702:0.108723 703:0.170078 704:0.0887182 705:0.19433 706:0.203472 707:0.256408 708:0.182657 709:0.121228 710:0.0930586 711:0.0820534 712:0.135671 713:0.0920392 714:0.178516 715:0.220795 716:0.256408 717:0.256408 718:0.207581 719:0.130461 720:0.0700859 721:0.119967 722:0.0945054 723:0.108038 724:0.158225 725:0.172115 726:0.149503 727:0.130036 728:0.0788522 729:0.136299 730:0.165995 731:0.139473 732:0.226551 733:0.220402 734:0.226551 735:0.205696 736:0.121995 737:0.12631 738:0.178081 739:0.200992 740:0.171977 741:0.170857 742:0.15123 743:0.223725 744:0.132559 745:0.146245 746:0.124028 747:0.149996 748:0.226551 749:0.123297 750:0.191264 751:0.165222 752:0.226551 753:0.221732 754:0.145904 755:0.10998 756:0.166489 757:0.128567 758:0.1069 759:0.237328 760:0.185708 761:0.218447 762:0.237578 763:0.152745 764:0.131531 765:0.141455 766:0.089619 767:0.0690976 768:0.113697 769:0.160673 770:0.16654 771:0.237578 772:0.153539 773:0.212842 774:0.1972 775:0.151109 776:0.0810687 777:0.134095 778:0.106552 779:0.237578 780:0.237578 781:0.204477 782:0.0675014 783:0.0740456 784:0.109949 785:0.103149 786:0.180932 787:0.167196 788:0.237578 789:0.237578 790:0.173121 791:0.0906037 792:0.11224 793:0.0537041 794:0.0835037 795:0.14455 796:0.226888 797:0.240534 798:0.223111 799:0.137546 800:0.156178 801:0.161526 802:0.0745361 803:0.102077 804:0.163531 805:0.158682 806:0.241481 807:0.205895 808:0.136551 809:0.072126 810:0.0728925 811:0.0815823 812:0.146696 813:0.243165 814:0.243165 815:0.243165 816:0.143359 817:0.135239 818:0.0858351 819:0.168148 820:0.0971405 821:0.137365 822:0.243165 823:0.23676 824:0.243165 825:0.187543 826:0.0802433 827:0.0949731 828:0.0850998 829:0.110978 830:0.0744459 831:0.134252 832:0.131017 833:0.197098 834:0.142086 835:0.123014 836:0.0888997 837:0.059911 838:0.117134 839:0.121659 840:0.159152 841:0.192528 842:0.258118 843:0.220797 844:0.152312 845:0.0888315 846:0.0572962 847:0.135076 848:0.106097 849:0.216091 850:0.232898 851:0.258118 852:0.133905 853:0.109726 854:0.133614 855:0.0852246 856:0.160699 857:0.231338 858:0.213403 859:0.258118 860:0.258118 861:0.258118 862:0.165642 863:0.0809806 864:0.0845187
So I want to parsing it from chars to float and then I want to use that for hog.setSVMdetector(const vector<float>& detector);
This is my code for parsing.
#include <jni.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <android/log.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc_c.h>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <vector>
#include <android/log.h>
#include <opencv2/ml/ml.hpp>
#define LOG_TAG "TourGuide"
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
typedef struct {
char index[2]; ////for example 1-99
char filler[1]; //for ":"
float value; // for "0.0516209"
char space[1]; // for " "
}img_vector;
typedef struct {
char img_type[2];
char space[1];
img_vector value[61344];
} img_dat;
using namespace std;
using namespace cv;
vector<float> parseToVector(char* data_i)
{
int i=0;
vector<float> temp_vect;
char temp_buf[20971520];
int cur_vector =0 ;
char temp_float[8+1]; // assume float max 11 digit
memset(temp_float,0, sizeof(temp_float));
char temp_index[2+1];
memset(temp_index, 0, sizeof(temp_index));
int state = 0; //when getting data, there's 3 state
//state 0 -> getting index
// state 1 -> getting filler ':'
// state 2 -> getting float
// state 3 -> getting space
img_dat images;
int data_length = strlen(data_i);
memset(temp_buf, 0, sizeof(temp_buf));
memcpy(temp_buf, data_i, data_length);
//get img_type
memcpy((char*)&images.img_type, temp_buf, 3); // get +1 and space
data_length -= 3; //already parsed 3 bytes of data
//i start from string number 3
for (i =3; i<data_length; i++){
if(state == 0) {
if (temp_buf[i] != ':'){
temp_index[strlen(temp_index)] = temp_buf[i];
}
else {
memcpy(images.value[cur_vector].index, temp_index, strlen(temp_index));
memset(temp_index,0, sizeof(temp_index));
state = 1;
i--; // step back
}
} else if (state == 1){
if (temp_buf[i] == ':'){
memcpy(images.value[cur_vector].filler, (char*)&temp_buf[i], 1);
state = 2;
}
} else if (state == 2){
if ((temp_buf[i] != ' ') && strlen(temp_float) < 12){
temp_float[strlen(temp_float)] = temp_buf[i];
}
else {
images.value[cur_vector].value = atof(temp_float);
memset(temp_float, 0, sizeof(temp_float));
state = 3;
i--; //step back
}
} else if (state ==3) {
if (temp_buf[i] == ' '){
memcpy(images.value[cur_vector].space, (char*)&temp_buf[i], 1);
state = 0;
cur_vector++;
}
}
}
for (int j =0; j<cur_vector;j++){
temp_vect[j] = images.value[cur_vector].value;
}
return temp_vect;
}
extern "C"
jboolean
Java_com_example_franksyesipangkar_tourguide_CameraPreview_ImageProcessing
(JNIEnv* env, jobject thiz, jint width, jint height, jbyteArray NV21FrameData, jintArray outPixels, jbyteArray s)
{
LOGD("JNIEnv");
//convert jbyteArray to char
jbyte *cmd = env->GetByteArrayElements(s, 0);
LOGD("JNIEnvFeature");
//char * feature = (char *)cmd;
char feature[819000];//[819000] 800kb for size file
memset(feature,0, sizeof(feature));
//memcpy(feature, cmd, strlen((char*)cmd));
memcpy(feature, cmd+1024, 1024);
vector<float> VFeature;
VFeature = parseToVector(feature);
LOGD("ParseToVector");
When I run/debug it in Android Studio, I have an error in logcat.I think in this process
vector<float> VFeature;
VFeature = parseToVector(feature);
I get the following error:
12-24 22:42:54.696 29947-30010/? E/TopActivity﹕ -com.example.franksyesipangkar.tourguide
12-24 22:42:54.782 2667-2667/? E/﹕ appName=com.example.franksyesipangkar.tourguide, acAppName=/system/bin/surfaceflinger
12-24 22:42:55.666 2667-2667/? A/libc﹕ Fatal signal 11 (SIGSEGV) at 0xbd86a624 (code=1), thread 2667 (ngkar.tourguide)
12-24 22:42:56.056 21711-21754/? E/InputDispatcher﹕ channel '42d398e0 com.example.franksyesipangkar.tourguide/com.example.franksyesipangkar.tourguide.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
12-24 22:44:30.395 2882-2882/? I/DEBUG﹕ #01 pc 00058435 /data/app-lib/com.example.franksyesipangkar.tourguide-1/libImageProcessing.so (parseToVector(char*)+64)
What do you think for this problem?
One problem I see is that in img_vector you only allocate space for a 2 digit index(char index[2]; ////for example 1-99) but the indexes in your data go up to 3 digits.
That said the way you are extracting the floats from the file looks like a big mess. If you only need to get all f the floating point numbers from one of those lines then you can use
std::string line = "+1 1:0.0516209 2:0.0526671 3:0.0621273 4:0.162602 5:0.252267 6:0.220246 7:0.116933 8:0.0665012 9:0.040535 10:0.0810178 11:0.0799648 12:0.0989393 13:0.204468 14:0.252267 15:0.232619 16:0.10104 17:0.0503855 18:0.0872255 19:0.109535 20:0.135352 21:0.252267 22:0.252267 23:0.252267 24:0.19159 25:0.139957 26:0.0849861 27:0.0621954 28:0.180085 29:0.220934 30:0.252267 31:0.252267 32:0.252267 33:0.14686 34:0.133376 35:0.0798698 36:0.143804 37:0.154667 38:0.175837 39:0.175819 40:0.185156 41:0.242682 42:0.143323 43:0.0656771 44:0.0752698 45:0.120002 46:0.125042 47:0.137929 48:0.141668 49:0.238362 50:0.242682 51:0.187268 52:0.0587663 53:0.0820198 54:0.0561508 55:0.173739 56:0.235661 57:0.176866 58:0.242682 59:0.242682 60:0.120697 61:0.0926801 62:0.074838 63:0.120294 64:0.099418 65:0.165938 66:0.223667 67:0.242682 68:0.242682 69:0.242682 70:0.0941423 71:0.0576666 72:0.0232888 73:0.030905 74:0.0741619 75:0.128762 76:0.241179 77:0.284917 78:0.284917 79:0.0878371 80:0.057604 81:0.0254226 82:0.0749189 83:0.0660299 84:0.112901 85:0.165158 86:0.284917 87:0.205528 88:0.0918434 89:0.0600073 90:0.0772874 91:0.0374085 92:0.119716 93:0.183876 94:0.237916 95:0.284917 96:0.284917 97:0.11597 98:0.0431861 99:0.0226412 100:0.053028 101:0.0779262 102:0.138294 103:0.197107 104:0.284917 105:0.284917 106:0.155058 107:0.09058 108:0.0685508 109:0.107512 110:0.0580869 111:0.155158 112:0.243893 113:0.215341 114:0.129598 115:0.048822 116:0.0425757 117:0.0809534 118:0.1627 119:0.124774 120:0.198517 121:0.259591 122:0.259591 123:0.109071 124:0.0437223 125:0.0560505 126:0.0753148 127:0.0582958 128:0.0646337 129:0.207277 130:0.259591 131:0.248938 132:0.259591 133:0.135874 134:0.113958 135:0.061379 136:0.0877517 137:0.115159 138:0.223133 139:0.259591 140:0.259591 141:0.259591 142:0.135361 143:0.0905518 144:0.0649403 145:0.104641 146:0.139505 147:0.234039 148:0.234039 149:0.209601 150:0.213197 151:0.132382 152:0.0932568 153:0.0901358 154:0.185335 155:0.232361 156:0.234039 157:0.234039 158:0.154098 159:0.167337 160:0.179891 161:0.118966 162:0.131475 163:0.0564679 164:0.105363 165:0.167412 166:0.231988 167:0.228415 168:0.228708 169:0.104494 170:0.072458 171:0.0586462 172:0.0992585 173:0.117884 174:0.104316 175:0.151379 176:0.187837 177:0.156796 178:0.232444 179:0.139886 180:0.0964207 181:0.145255 182:0.198792 183:0.150749 184:0.221525 185:0.19881 186:0.178096 187:0.226074 188:0.121964 189:0.102861 190:0.0437534 191:0.131493 192:0.178541 193:0.21926 194:0.234759 195:0.254669 196:0.157603 197:0.0723847 198:0.0244493 199:0.065348 200:0.0853451 201:0.0624319 202:0.103251 203:0.139865 204:0.220055 205:0.254669 206:0.223438 207:0.0848672 208:0.0425032 209:0.0791857 210:0.138352 211:0.157657 212:0.200656 213:0.254669 214:0.254669 215:0.167132 216:0.0369475 217:0.0398139 218:0.124495 219:0.180236 220:0.185851 221:0.262945 222:0.262945 223:0.142996 224:0.09139 225:0.0423195 226:0.0673232 227:0.067754 228:0.118807 229:0.177049 230:0.217177 231:0.262945 232:0.206083 233:0.154343 234:0.129637 235:0.071941 236:0.0843471 237:0.154425 238:0.167051 239:0.223171 240:0.262945 241:0.230233 242:0.168113 243:0.0707214 244:0.0988057 245:0.110709 246:0.10464 247:0.170808 248:0.142613 249:0.198069 250:0.193661 251:0.206063 252:0.139514 253:0.070888 254:0.0546235 255:0.0987665 256:0.179403 257:0.176451 258:0.231507 259:0.170609 260:0.170777 261:0.134404 262:0.0957243 263:0.0741578 264:0.113292 265:0.210238 266:0.215958 267:0.264889 268:0.175568 269:0.120427 270:0.0934888 271:0.107025 272:0.127747 273:0.0658595 274:0.172265 275:0.187371 276:0.264889 277:0.179685 278:0.217699 279:0.124863 280:0.140482 281:0.0842961 282:0.0816219 283:0.186152 284:0.26147 285:0.264889 286:0.14057 287:0.18035 288:0.149876 289:0.0789043 290:0.170528 291:0.259454 292:0.244211 293:0.259454 294:0.255461 295:0.124829 296:0.0738446 297:0.0424127 298:0.197806 299:0.162143 300:0.144715 301:0.122082 302:0.171563 303:0.123079 304:0.188536 305:0.128817 306:0.0890725 307:0.0940822 308:0.185499 309:0.259454 310:0.252905 311:0.211187 312:0.161549 313:0.115569 314:0.0730725 315:0.0770362 316:0.226353 317:0.181456 318:0.223296 319:0.170029 320:0.117185 321:0.0981806 322:0.0746445 323:0.060523 324:0.0916957 325:0.0950073 326:0.0789168 327:0.0433256 328:0.0477858 329:0.109855 330:0.13269 331:0.207804 332:0.182029 333:0.0941013 334:0.118187 335:0.0871392 336:0.0667544 337:0.125589 338:0.256858 339:0.254672 340:0.256858 341:0.219227 342:0.102974 343:0.160436 344:0.140071 345:0.0956094 346:0.0954186 347:0.105212 348:0.0769432 349:0.134467 350:0.104214 351:0.153261 352:0.236158 353:0.218971 354:0.134611 355:0.232192 356:0.256858 357:0.160758 358:0.229581 359:0.215932 360:0.256858 361:0.131302 362:0.0838311 363:0.0680505 364:0.0964724 365:0.167542 366:0.163733 367:0.159702 368:0.11763 369:0.0803405 370:0.147074 371:0.153463 372:0.141674 373:0.108444 374:0.110367 375:0.155245 376:0.0968434 377:0.0853039 378:0.0769986 379:0.233289 380:0.184741 381:0.148944 382:0.195778 383:0.249193 384:0.148996 385:0.183793 386:0.157546 387:0.249193 388:0.249193 389:0.249193 390:0.249193 391:0.16308 392:0.180707 393:0.154442 394:0.126717 395:0.145393 396:0.249193 397:0.0897672 398:0.14826 399:0.16095 400:0.191101 401:0.183119 402:0.242813 403:0.0559302 404:0.0604032 405:0.0441353 406:0.0892086 407:0.0911337 408:0.0933983 409:0.204716 410:0.249644 411:0.24499 412:0.0836525 413:0.0743139 414:0.0867809 415:0.230095 416:0.209791 417:0.249644 418:0.249644 419:0.203505 420:0.169885 421:0.0601984 422:0.0619023 423:0.149432 424:0.095661 425:0.119704 426:0.185102 427:0.249644 428:0.249644 429:0.2331 430:0.172669 431:0.0571165 432:0.0554624 433:0.105544 434:0.124474 435:0.204209 436:0.149226 437:0.287671 438:0.233312 439:0.158538 440:0.085772 441:0.102165 442:0.117022 443:0.122671 444:0.160237 445:0.151971 446:0.143499 447:0.129942 448:0.0959389 449:0.0556028 450:0.0864025 451:0.167466 452:0.0568043 453:0.105169 454:0.28099 455:0.287671 456:0.287671 457:0.203573 458:0.0838686 459:0.125802 460:0.19001 461:0.0978778 462:0.118772 463:0.103927 464:0.206477 465:0.221949 466:0.147634 467:0.109453 468:0.21046 469:0.0934628 470:0.111775 471:0.0854255 472:0.0896416 473:0.0980298 474:0.0729928 475:0.101601 476:0.0468797 477:0.0791986 478:0.158492 479:0.162197 480:0.188256 481:0.310893 482:0.298819 483:0.152905 484:0.154461 485:0.104955 486:0.219529 487:0.105981 488:0.109796 489:0.0943929 490:0.116314 491:0.211338 492:0.183864 493:0.15099 494:0.0466525 495:0.0814759 496:0.0826441 497:0.133331 498:0.189644 499:0.310893 500:0.310893 501:0.310893 502:0.178649 503:0.0622459 504:0.0721505 505:0.161893 506:0.112677 507:0.17197 508:0.261516 509:0.231606 510:0.12838 511:0.119647 512:0.0897209 513:0.204429 514:0.258437 515:0.151017 516:0.232684 517:0.106046 518:0.119519 519:0.118933 520:0.102533 521:0.109681 522:0.261516 523:0.0781687 524:0.0865439 525:0.120502 526:0.261516 527:0.261516 528:0.261516 529:0.0982907 530:0.0651658 531:0.0631546 532:0.205084 533:0.151398 534:0.215174 535:0.0894046 536:0.133384 537:0.157612 538:0.100458 539:0.0809739 540:0.148817 541:0.239039 542:0.163965 543:0.24837 544:0.147138 545:0.137003 546:0.198188 547:0.0955781 548:0.0704638 549:0.201737 550:0.09251 551:0.13307 552:0.203236 553:0.230284 554:0.24581 555:0.24837 556:0.163676 557:0.0441309 558:0.05486 559:0.200242 560:0.18874 561:0.24837 562:0.122286 563:0.111089 564:0.170059 565:0.0974838 566:0.0557162 567:0.139893 568:0.142029 569:0.135066 570:0.239535 571:0.165015 572:0.151529 573:0.215339 574:0.109499 575:0.0477798 576:0.102104 577:0.142869 578:0.0506508 579:0.099281 580:0.311296 581:0.311296 582:0.29235 583:0.0853785 584:0.0298867 585:0.0839334 586:0.217339 587:0.102943 588:0.0936696 589:0.0937782 590:0.148731 591:0.120643 592:0.0644866 593:0.105494 594:0.223154 595:0.124304 596:0.0630043 597:0.0882641 598:0.290856 599:0.311296 600:0.311296 601:0.159524 602:0.0136488 603:0.0657668 604:0.204307 605:0.149414 606:0.111302 607:0.106827 608:0.11079 609:0.117657 610:0.0400945 611:0.0877738 612:0.183063 613:0.133036 614:0.11257 615:0.114527 616:0.079359 617:0.144871 618:0.166868 619:0.0980467 620:0.0701586 621:0.136393 622:0.144127 623:0.204131 624:0.184349 625:0.273352 626:0.273352 627:0.273352 628:0.117483 629:0.0403787 630:0.101049 631:0.154879 632:0.180959 633:0.167622 634:0.138856 635:0.0361039 636:0.0806388 637:0.0373684 638:0.0916881 639:0.156742 640:0.223871 641:0.273352 642:0.271826 643:0.273352 644:0.165789 645:0.124406 646:0.0731598 647:0.143914 648:0.174675 649:0.112238 650:0.164751 651:0.0874189 652:0.161027 653:0.280177 654:0.223749 655:0.0456342 656:0.0362706 657:0.0407592 658:0.236262 659:0.280177 660:0.280177 661:0.0951557 662:0.137062 663:0.0833213 664:0.0380415 665:0.0730444 666:0.0742162 667:0.173875 668:0.280177 669:0.210483 670:0.195704 671:0.156123 672:0.0756225 673:0.0553245 674:0.106288 675:0.11255 676:0.231428 677:0.280177 678:0.280177 679:0.132035 680:0.0793173 681:0.0650503 682:0.0857836 683:0.126709 684:0.141397 685:0.215868 686:0.298669 687:0.298669 688:0.208136 689:0.0907796 690:0.0632681 691:0.0523893 692:0.0769242 693:0.0955798 694:0.0874953 695:0.098873 696:0.244548 697:0.186292 698:0.111636 699:0.105521 700:0.0849176 701:0.0982519 702:0.0771137 703:0.180454 704:0.298669 705:0.298669 706:0.255643 707:0.0955855 708:0.0588408 709:0.0775926 710:0.161626 711:0.132766 712:0.078477 713:0.0844616 714:0.298669 715:0.242583 716:0.107347 717:0.0798445 718:0.0853468 719:0.103689 720:0.065806 721:0.0357221 722:0.0298848 723:0.0814559 724:0.167687 725:0.266033 726:0.266033 727:0.250278 728:0.0899015 729:0.0693378 730:0.074513 731:0.0717591 732:0.120642 733:0.0856944 734:0.0741726 735:0.111318 736:0.0733351 737:0.111474 738:0.102383 739:0.0333341 740:0.0476535 741:0.090083 742:0.119321 743:0.266033 744:0.266033 745:0.266033 746:0.266033 747:0.186286 748:0.126744 749:0.0692135 750:0.161342 751:0.110722 752:0.266033 753:0.180974 754:0.180172 755:0.266033 756:0.23479 757:0.117383 758:0.159488 759:0.246485 760:0.240844 761:0.0489906 762:0.0327636 763:0.0302243 764:0.0614286 765:0.0963371 766:0.174301 767:0.246485 768:0.246485 769:0.246485 770:0.0998213 771:0.0707082 772:0.0477948 773:0.138016 774:0.121114 775:0.204169 776:0.113 777:0.246485 778:0.220392 779:0.246485 780:0.113499 781:0.046402 782:0.0894608 783:0.168363 784:0.192057 785:0.17405 786:0.246485 787:0.221395 788:0.227333 789:0.139138 790:0.0606163 791:0.0669251 792:0.162615 793:0.168169 794:0.264854 795:0.243766 796:0.140564 797:0.0976328 798:0.0677347 799:0.0445176 800:0.15511 801:0.15869 802:0.264854 803:0.264854 804:0.246155 805:0.104299 806:0.0436364 807:0.0780234 808:0.131923 809:0.166165 810:0.2136 811:0.132863 812:0.238265 813:0.157387 814:0.103066 815:0.151245 816:0.096932 817:0.0574446 818:0.107677 819:0.132774 820:0.238755 821:0.264854 822:0.112574 823:0.141528 824:0.182357 825:0.106048 826:0.12458 827:0.150181 828:0.164209 829:0.24785 830:0.24785 831:0.24785 832:0.191579 833:0.0602815 834:0.0766117 835:0.118639 836:0.180041 837:0.177137 838:0.0915748 839:0.10766 840:0.24785 841:0.199659 842:0.0899677 843:0.130194 844:0.105077 845:0.0814451 846:0.0724681 847:0.220688 848:0.24785 849:0.145892 850:0.207808 851:0.151263 852:0.0936182 853:0.13452 854:0.151408 855:0.202105 856:0.107693 857:0.143771 858:0.233332 859:0.201684 860:0.184008 861:0.147185 862:0.120236 863:0.101269 864:0.155512";
std::vector<float> floats;
float temp;
std::string eater;
std::stringstream ss(line);
while (std::getline(ss, eater, ':')) // eat input till : and toss out :
{
ss >> temp;
floats.push_back(temp);
}
Also in C++ it is not considered good practice to use
typedef struct {
char index[2]; ////for example 1-99
char filler[1]; //for ":"
float value; // for "0.0516209"
char space[1]; // for " "
}img_vector;
Instead you should use
struct img_vector{
char index[2]; ////for example 1-99
char filler[1]; //for ":"
float value; // for "0.0516209"
char space[1]; // for " "
};