Skip to content

Commit

Permalink
Issue opencv#2547 Native camera does not work on Google Nexus 7 with …
Browse files Browse the repository at this point in the history
…Android 4.2 fixed;

Issue opencv#2506 Unnecessary log printouts in OpenCV::camera fixed;
Native camera for MIPS Android 4.1.1 added.
Build script for camera updated.
  • Loading branch information
asmorkalov committed Nov 21, 2012
1 parent 6cd70c8 commit aa4e6a8
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 13 deletions.
Empty file modified 3rdparty/lib/armeabi-v7a/libnative_camera_r2.3.3.so
100644 → 100755
Empty file.
Empty file modified 3rdparty/lib/armeabi-v7a/libnative_camera_r4.1.1.so
100644 → 100755
Empty file.
Binary file not shown.
Empty file modified 3rdparty/lib/armeabi/libnative_camera_r4.1.1.so
100644 → 100755
Empty file.
Binary file added 3rdparty/lib/armeabi/libnative_camera_r4.2.0.so
Binary file not shown.
Empty file modified 3rdparty/lib/mips/libnative_camera_r4.0.3.so
100644 → 100755
Empty file.
Binary file added 3rdparty/lib/mips/libnative_camera_r4.1.1.so
Binary file not shown.
Binary file added 3rdparty/lib/mips/libnative_camera_r4.2.0.so
Binary file not shown.
Empty file modified 3rdparty/lib/x86/libnative_camera_r4.1.1.so
100644 → 100755
Empty file.
Binary file added 3rdparty/lib/x86/libnative_camera_r4.2.0.so
Binary file not shown.
5 changes: 5 additions & 0 deletions android/scripts/camera_build.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ native_camera_r4.0.0; armeabi-v7a; 14; /home/alexander/Projects/AndroidSource/4.
native_camera_r4.1.1; armeabi; 14; /home/alexander/Projects/AndroidSource/4.1.1
native_camera_r4.1.1; armeabi-v7a; 14; /home/alexander/Projects/AndroidSource/4.1.1
native_camera_r4.1.1; x86; 14; /home/alexander/Projects/AndroidSource/4.1.1
native_camera_r4.1.1; mips; 14; /home/alexander/Projects/AndroidSource/4.1.1_mips
native_camera_r4.2.0; armeabi-v7a; 14; /home/alexander/Projects/AndroidSource/4.2
native_camera_r4.2.0; armeabi; 14; /home/alexander/Projects/AndroidSource/4.2
native_camera_r4.2.0; x86; 14; /home/alexander/Projects/AndroidSource/4.2
native_camera_r4.2.0; mips; 14; /home/alexander/Projects/AndroidSource/4.2
19 changes: 13 additions & 6 deletions android/scripts/cmake_android_all_cameras.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,27 @@
continue

shutil.rmtree(os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"), ignore_errors=True)

LinkerLibs = os.path.join(AndroidTreeRoot, "bin_arm", "system")
if (Arch == "x86"):
shutil.copytree(os.path.join(AndroidTreeRoot, "bin_x86", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
LinkerLibs = os.path.join(AndroidTreeRoot, "bin_x86", "system")
elif (Arch == "mips"):
shutil.copytree(os.path.join(AndroidTreeRoot, "bin_mips", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
else:
shutil.copytree(os.path.join(AndroidTreeRoot, "bin_arm", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
LinkerLibs = os.path.join(AndroidTreeRoot, "bin_mips", "system")

if (not os.path.exists(LinkerLibs)):
print("Error: Paltform libs for linker in path \"%s\" not found" % LinkerLibs)
print("Building %s for %s\t[\033[91mFAILED\033[0m]" % (MakeTarget, Arch))
continue

shutil.copytree(LinkerLibs, os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))

os.chdir(BuildDir)
BuildLog = os.path.join(BuildDir, "build.log")
CmakeCmdLine = "cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_SOURCE_TREE=\"%s\" -DANDROID_NATIVE_API_LEVEL=\"%s\" -DANDROID_ABI=\"%s\" -DANDROID_STL=stlport_static ../../ > \"%s\" 2>&1" % (AndroidTreeRoot, NativeApiLevel, Arch, BuildLog)
MakeCmdLine = "make %s >> \"%s\" 2>&1" % (MakeTarget, BuildLog);
print(CmakeCmdLine)
#print(CmakeCmdLine)
os.system(CmakeCmdLine)
print(MakeCmdLine)
#print(MakeCmdLine)
os.system(MakeCmdLine)
os.chdir(HomeDir)
CameraLib = os.path.join(BuildDir, "lib", Arch, "lib" + MakeTarget + ".so")
Expand Down
10 changes: 5 additions & 5 deletions modules/androidcamera/camera_wrapper/camera_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !defined(ANDROID_r2_2_0) && !defined(ANDROID_r2_3_3) && !defined(ANDROID_r3_0_1) && !defined(ANDROID_r4_0_0) && !defined(ANDROID_r4_0_3) && !defined(ANDROID_r4_1_1)
#if !defined(ANDROID_r2_2_0) && !defined(ANDROID_r2_3_3) && !defined(ANDROID_r3_0_1) && !defined(ANDROID_r4_0_0) && !defined(ANDROID_r4_0_3) && !defined(ANDROID_r4_1_1) && !defined(ANDROID_r4_2_0)
# error Building camera wrapper for your version of Android is not supported by OpenCV. You need to modify OpenCV sources in order to compile camera wrapper for your version of Android.
#endif

Expand All @@ -18,7 +18,7 @@
# define MAGIC_OPENCV_TEXTURE_ID (0x10)
#else // defined(ANDROID_r3_0_1) || defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3)
//TODO: This is either 2.2 or 2.3. Include the headers for ISurface.h access
#if defined(ANDROID_r4_1_1)
#if defined(ANDROID_r4_1_1) || defined(ANDROID_r4_2_0)
#include <gui/ISurface.h>
#include <gui/BufferQueue.h>
#else
Expand Down Expand Up @@ -60,7 +60,7 @@ using namespace android;

void debugShowFPS();

#if defined(ANDROID_r4_1_1)
#if defined(ANDROID_r4_1_1) || defined(ANDROID_r4_2_0)
class ConsumerListenerStub: public BufferQueue::ConsumerListener
{
public:
Expand Down Expand Up @@ -280,7 +280,7 @@ class CameraHandler: public CameraListener
}

virtual void postData(int32_t msgType, const sp<IMemory>& dataPtr
#if defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) || defined(ANDROID_r4_1_1)
#if defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) || defined(ANDROID_r4_1_1) || defined(ANDROID_r4_2_0)
,camera_frame_metadata_t*
#endif
)
Expand Down Expand Up @@ -526,7 +526,7 @@ CameraHandler* CameraHandler::initCameraConnect(const CameraCallback& callback,
pdstatus = camera->setPreviewTexture(surfaceTexture);
if (pdstatus != 0)
LOGE("initCameraConnect: failed setPreviewTexture call; camera migth not work correctly");
#elif defined(ANDROID_r4_1_1)
#elif defined(ANDROID_r4_1_1) || defined(ANDROID_r4_2_0)
sp<BufferQueue> bufferQueue = new BufferQueue();
sp<BufferQueue::ConsumerListener> queueListener = new ConsumerListenerStub();
bufferQueue->consumerConnect(queueListener);
Expand Down
2 changes: 0 additions & 2 deletions modules/androidcamera/src/camera_activity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,15 +427,13 @@ void CameraActivity::applyProperties()

int CameraActivity::getFrameWidth()
{
LOGD("CameraActivity::getFrameWidth()");
if (frameWidth <= 0)
frameWidth = getProperty(ANDROID_CAMERA_PROPERTY_FRAMEWIDTH);
return frameWidth;
}

int CameraActivity::getFrameHeight()
{
LOGD("CameraActivity::getFrameHeight()");
if (frameHeight <= 0)
frameHeight = getProperty(ANDROID_CAMERA_PROPERTY_FRAMEHEIGHT);
return frameHeight;
Expand Down

0 comments on commit aa4e6a8

Please sign in to comment.