Jetson-inference Library Review

Posted

Source

An official jetson-inference lib. provided by Dystin Franklin (github)

Revising glDisplay

Add below code to file “/jetson-inference/utils/display/glDisplay.cpp”, lines~1367

LogInfo(LOG_GL "glDisplay -- event KEY_STATE %i %s (%s)\n", a, XKeysymToString(a), b ? "pressed" : "released");
display->mKeyStates[a] = (b == KEY_PRESSED)?1:0;
display->mCurKeyChar = (b == KEY_PRESSED)?(char)a:0;

Change encapsulation of mKeyState[] as public in file “/jetson-inference/utils/display/glDisplay.h”,lines~589 (move from line~683)

bool     mKeyStates[1024];
char     mCurKeyChar = 0;

Add following method to get key state, line~427

inline bool GetKeyI( int key ) const { return mKeyStates[key]; }
inline char GetCurKeyChar() const { return mCurKeyChar; }

Usage

Put this code in main func. of program

if(output->IsType<glDisplay>())
{
	glDisplay* dis = (glDisplay*)output;
	LogInfo(LOG_COLOR_YELLOW "Mouse-pos x,y & key: %u,%u,%u\n",dis->GetMousePosition()[0],dis->GetMousePosition()[1],dis->GetKeyI(XK_a));
}

Result

Author
Categories C++, Nvidia Jetson Nano