Ticket #33863

Re: NyARToolkit for BeagleBoard-xm (フォーラムメッセージ #73144 からの引用)

Open Date: 2014-05-24 03:33 Last Update: 2014-05-24 03:33

Reporter:
Owner:
(None)
Type:
Status:
Open
Component:
(None)
MileStone:
(None)
Priority:
9 - Highest
Severity:
5 - Medium
Resolution:
None
File:
None

Details

フォーラム Help [#73144] からの引用

[forum: 73144]

#73143 への返信

#73079 への返信

Hi, What's the error message? And Why do you use "private android.hardware.Camera mCameraDevice"? Regards, Noritsuna

Hi, Thanks for your answer, I want to explain better the situation. I opened NyARToolkitAndroid-2.5.2 project, there is a package with the following classes: jp.androidgroup.nyartoolkit.hardware -------> Package *CameraIF.java *Dev1Camera.java *HT03ACamera.java *N1Camera.java *SocketCamera.java *StaticCamera.java *UVCCamera.java I noticed that CameraIF.java class is an interface for cameras. In other package --------> jp.androidgroup.nyartoolkit, the class NyARToolkitAndroidActivity.java is the main class that choose the camera class in this line: // init Camera. ****** In case we are using UVCCamera class for example******** else if(getString(R.string.camera_name).equals("jp.androidgroup.nyartoolkit.hardware.UVCCamera")) { isUseSerface = true; if (mTranslucentBackground) { mGLSurfaceView = new GLSurfaceView(this); mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0); mGLSurfaceView.setRenderer(mRenderer); mGLSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT); SurfaceView mSurfaceView = new SurfaceView(this); mCameraDevice = new UVCCamera(this, mSurfaceView); mPreferences = PreferenceManager.getDefaultSharedPreferences(this); setContentView(mGLSurfaceView); addContentView(mSurfaceView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); } else { setContentView(R.layout.uvccamera); SurfaceView mSurfaceView = (SurfaceView) findViewById(R.id.UVC_camera_preview); mCameraDevice = new UVCCamera(this, mSurfaceView); mPreferences = PreferenceManager.getDefaultSharedPreferences(this); mGLSurfaceView = (GLSurfaceView) findViewById(R.id.UVC_GL_view); mGLSurfaceView.setRenderer(mRenderer); *********************************************************************** So, I decided to modify this class UVCCamera.java that was included originally in this package of the NyARToolkit, in this class they are using: private android.hardware.Camera mCameraDevice I added the following code to this class UVCCamera based on the example UVCCamerapreview you sent me: *************Here I added run method***************** But I'm not sure about mcameradevice, I don't know how to merge this run method in this case, but I dit it like this: public class ImageCapture { private boolean mCancel = false; /* * Initiate the capture of an image. */ public void initiate() { if (mCameraDevice == null) { return; } mCancel = true; capture(); } private void capture() { while (true && cameraExists) { //obtaining display area to draw a large image if(winWidth==0){ winWidth=this.getWidth(); winHeight=this.getHeight(); if(winWidth*3/4<=winHeight){ dw = 0; dh = (winHeight-winWidth*3/4)/2; rate = ((float)winWidth)/IMG_WIDTH; rect = new Rect(dw,dh,dw+winWidth-1,dh+winWidth*3/4-1); }else{ dw = (winWidth-winHeight*4/3)/2; dh = 0; rate = ((float)winHeight)/IMG_HEIGHT; rect = new Rect(dw,dh,dw+winHeight*4/3 -1,dh+winHeight-1); } } // obtaining a camera image (pixel data are stored in an array in JNI). processCamera(); // camera image to bmp pixeltobmp(bmp); Canvas canvas = getHolder().lockCanvas(); if (canvas != null) { // draw camera bmp on canvas canvas.drawBitmap(bmp,null,rect,null); getHolder().unlockCanvasAndPost(canvas); } if(shouldStop){ shouldStop = false; break; } } mCameraDevice.setParameters(mParameters); // mCameraDevice.takePicture(null, null, new JpegPictureCallback(loc)); mPreviewing = false; } ***************************Then I modified****************************************************** public void surfaceCreated(SurfaceHolder holder) { Log.d(TAG, "surfaceCreated"); if(DEBUG) Log.d(TAG, "surfaceCreated"); if(bmp==null){ bmp = Bitmap.createBitmap(mViewFinderWidth, mViewFinderHeight, Bitmap.Config.ARGB_8888); } // /dev/videox (x=cameraId + cameraBase) is used int ret = prepareCameraWithBase(cameraId, cameraBase); if(ret!=-1) cameraExists = true; mainLoop = new Thread((Runnable) this); mainLoop.start(); } *********************************And finally I modified this********************************************************** public void surfaceDestroyed(SurfaceHolder holder) { Log.d(TAG, "surfaceDestroyed"); if(DEBUG) Log.d(TAG, "surfaceDestroyed"); if(cameraExists){ shouldStop = true; while(shouldStop){ try{ Thread.sleep(100); // wait for thread stopping }catch(Exception e){} } } stopCamera(); mSurfaceHolder = null; } ************************************************************************************* When I excecute the app, it says unfortunately the app has to stop, the problem is in this line of the class: NyARToolkitAndroidActivity.java-------> Class Line 198---->mCameraDevice = new UVCCamera(this, mSurfaceView); In this class mCameraDevice is defined as: private CameraIF mCameraDevice; *****************************Conclusion************************************************** Do you think is better to modify another class of the NyARToolkit?, for example the HT03ACamera class, maybe I have unnecessary information in UVCCameraclass, I want to make clear that UVCCamera class IS NOT the class you sent me, is a class included in the original package and I'm modifying it. Can you explain me with more details how to merge the code of WebCamera with the NyARToolkit in this case ?. Thanks a lot.

Ticket History (1/1 Histories)

2014-05-24 03:33 Updated by: johanna2
  • New Ticket "Re: NyARToolkit for BeagleBoard-xm (フォーラムメッセージ #73144 からの引用)" created

Attachment File List

No attachments

Edit

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Login