Merge pull request #1094 from asmorkalov:android_na_fix
This commit is contained in:
commit
1a2458885b
@ -20,7 +20,7 @@
|
|||||||
<folderInfo id="0.882924228." name="/" resourcePath="">
|
<folderInfo id="0.882924228." name="/" resourcePath="">
|
||||||
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1667980868" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
|
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1667980868" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
|
||||||
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1667980868.2108168132" name=""/>
|
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1667980868.2108168132" name=""/>
|
||||||
<builder autoBuildTarget="" command=""${NDKROOT}/ndk-build.cmd"" enableAutoBuild="true" enableCleanBuild="false" id="org.eclipse.cdt.build.core.settings.default.builder.328915772" incrementalBuildTarget="" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
|
<builder autoBuildTarget="" command="${NDKROOT}/ndk-build.cmd" enableAutoBuild="true" enableCleanBuild="false" id="org.eclipse.cdt.build.core.settings.default.builder.328915772" incrementalBuildTarget="" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
|
||||||
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.630148311" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
|
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.630148311" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
|
||||||
<tool id="org.eclipse.cdt.build.core.settings.holder.525090327" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
|
<tool id="org.eclipse.cdt.build.core.settings.holder.525090327" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1491216279" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1491216279" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
<activity android:name="CvNativeActivity"
|
<activity android:name="CvNativeActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
android:screenOrientation="landscape"
|
||||||
android:configChanges="orientation|keyboardHidden">
|
android:configChanges="orientation|keyboardHidden">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
@ -17,7 +18,9 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="android.app.NativeActivity"
|
<activity android:name="android.app.NativeActivity"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name"
|
||||||
|
android:screenOrientation="landscape"
|
||||||
|
android:configChanges="keyboardHidden|orientation">
|
||||||
<meta-data android:name="android.app.lib_name"
|
<meta-data android:name="android.app.lib_name"
|
||||||
android:value="native_activity" />
|
android:value="native_activity" />
|
||||||
</activity>
|
</activity>
|
||||||
|
@ -7,7 +7,7 @@ include ../../sdk/native/jni/OpenCV.mk
|
|||||||
LOCAL_MODULE := native_activity
|
LOCAL_MODULE := native_activity
|
||||||
LOCAL_SRC_FILES := native.cpp
|
LOCAL_SRC_FILES := native.cpp
|
||||||
LOCAL_LDLIBS += -lm -llog -landroid
|
LOCAL_LDLIBS += -lm -llog -landroid
|
||||||
LOCAL_STATIC_LIBRARIES := android_native_app_glue
|
LOCAL_STATIC_LIBRARIES += android_native_app_glue
|
||||||
|
|
||||||
include $(BUILD_SHARED_LIBRARY)
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
|
||||||
|
@ -78,18 +78,29 @@ static void engine_draw_frame(Engine* engine, const cv::Mat& frame)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* pixels = buffer.bits;
|
int32_t* pixels = (int32_t*)buffer.bits;
|
||||||
|
|
||||||
int left_indent = (buffer.width-frame.cols)/2;
|
int left_indent = (buffer.width-frame.cols)/2;
|
||||||
int top_indent = (buffer.height-frame.rows)/2;
|
int top_indent = (buffer.height-frame.rows)/2;
|
||||||
|
|
||||||
for (int yy = top_indent; yy < std::min(frame.rows+top_indent, buffer.height); yy++)
|
if (top_indent > 0)
|
||||||
{
|
{
|
||||||
unsigned char* line = (unsigned char*)pixels + left_indent*4*sizeof(unsigned char);
|
memset(pixels, 0, top_indent*buffer.stride*sizeof(int32_t));
|
||||||
size_t line_size = std::min(frame.cols, buffer.width)*4*sizeof(unsigned char);
|
pixels += top_indent*buffer.stride;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int yy = 0; yy < frame.rows; yy++)
|
||||||
|
{
|
||||||
|
if (left_indent > 0)
|
||||||
|
{
|
||||||
|
memset(pixels, 0, left_indent*sizeof(int32_t));
|
||||||
|
memset(pixels+left_indent+frame.cols, 0, (buffer.stride-frame.cols-left_indent)*sizeof(int32_t));
|
||||||
|
}
|
||||||
|
int32_t* line = pixels + left_indent;
|
||||||
|
size_t line_size = frame.cols*4*sizeof(unsigned char);
|
||||||
memcpy(line, frame.ptr<unsigned char>(yy), line_size);
|
memcpy(line, frame.ptr<unsigned char>(yy), line_size);
|
||||||
// go to next line
|
// go to next line
|
||||||
pixels = (int32_t*)pixels + buffer.stride;
|
pixels += buffer.stride;
|
||||||
}
|
}
|
||||||
ANativeWindow_unlockAndPost(engine->app->window);
|
ANativeWindow_unlockAndPost(engine->app->window);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user