19 Replies Latest reply on Oct 25, 2012 2:06 PM by Jay Fisher

    ET1: Access camera from hybrid application - Is there a way?

      I am writing a hybrid application that needs to be able to access the camera on the ET1. If there is no access via javascript, what is the preferred method to use? Hopefully the answer is not to rewrite as a native application.

       

      Any suggestions would be greatly appreciated.

        • Re: ET1: Access camera from hybrid application - Is there a way?
          Peter Arcuri

          The term Hybrid implies some native code... perhaps this proves to be helpful.

           

          Extended API for Motorola devices (RhoElements applications)

          Take a picture:

          Camera::take_picture('/app/model/camera_callback', options_hash) 

          options_hash – hash contain additional parameters :

          • “left” – number, camera left position in pixels. Default value = 0
          • “top” – number, camera top position in pixels. Default value = 0
          • “desired_width” – number, desired width in pixels. Default value = max camera width
          • “desired_height” – number, desired height in pixels. Default value = max camera height

          Sample

          See controller and view in the /app/Image folder of the System API Samples application for more information.

          • Re: ET1: Access camera from hybrid application - Is there a way?
            Robert Galvin

            Hi Jay  Actually you need to use the Imager API for the ET1 (Using the rhoelements runtime or app_type:rhoelements in a native model).  There are code snippets at: http://docs.rhomobile.com/rhoelements/imager

              • Re: ET1: Access camera from hybrid application - Is there a way?

                I was hopeful at first since the examples allowed me to figure out how to activate the camera (although all 'meta' tag values had to be transposed into the equivalent javascript format).  After a number of hours attempting to capture an image to a file I resorted to running through an example to get a working sample and hopefully to get a handle on how to use the imager object with javascript. Unfortunately the example code does not seem to work properly and there are syntax errors and malformed html. To get around this I attempted to enumerate the properties of the 'imager' object to get get a good list of object properties. This (javascript snippet below) resulted in a RhoElements runtime error and subsequent dump/force close message.

                 

                for(var prop in imager)

                    {

                     if(imager.hasOwnProperty(prop))

                      alert(imager[prop]);

                    }

                 

                It appears the the "imagerCaptureEvent" does not get wired up using javascript or html meta tags (tried it both ways - is this the correct name?). I am assuming that the event should fire when an image is captured.

                <META HTTP-Equiv="Imager" Content="imagerCaptureEvent:url('Javascript:onImageCapture(%json)');">

                imager.imagerCaptureEvent=onImageCapture(%json)';

                 

                Is there more up to date and complete documentation available? Or am I completely off track and doing this the wrong way? Any advice or help would be greatly appreciated.

                 

                Jay

                  • Re: ET1: Access camera from hybrid application - Is there a way?

                    Additional info: It appears that "imagerCaptureEvent" may not be the correct attribute name for the imager object's event. Some experimentation shows that any invalid name is ignored in javascript and does not throw any exception other than subsequent events not firing.

                      • Re: ET1: Access camera from hybrid application - Is there a way?
                        Stephen Skidmore

                        Jay,

                         

                        I have been working on the same issue.  I cannot raise a capture event even though I can enable and capture using the imager object.  I have spoken to some local Motorola folks, they agree and yesterday submitted a support ticket.  At their suggestion I tried to enable cam1 and found that it will raise capture events all day long. They also tried earlier OS and runtime releases.  None made it better, some made it worse.  My ET1 has the accessory scanner so I removed it and retested, no change.  I think the only thing left is firmware?  When they get an answer I'll update this thread if they do not do it sooner.

                         

                        Steve

                  • Re: ET1: Access camera from hybrid application - Is there a way?
                    Robert Galvin

                    Ok having the external MSR is accessory will impact how many "imagers' are on the device. What specific version of Andoid/ET1 software is being used? You should be using what has been called 'Rev C' or if you Settings/about device/Build number

                     

                    Capture.PNG

                    Also are you using pre-production devices/accessories? Also what version of RhoElements are you using. You should be using 2.1.1.7

                      • Re: ET1: Access camera from hybrid application - Is there a way?

                        Rob,

                         

                        I verified that all versions match those that you listed. Both ET1 devices purchased less than 1 month ago and updated with latest OS last week.

                         

                        Imager Enumeration on device:

                        ET1_ImagerEnum.jpg

                        • Re: ET1: Access camera from hybrid application - Is there a way?
                          Stephen Skidmore

                          Rob,

                           

                          I don't mean to hijack Jay's thread but I'm not sure if you're asking me or Jay.

                           

                          I don't have the MSR, we're using the ET1 scanner module.  It makes sense that it would be counted as the third imager by the device but it is not included in the list when imagerEnum returns.  Likewise, removing it had no effect.

                           

                          Android Ver 2.3.4

                          Bootloader Ver 1.1.4

                          Kernel Ver 2.6.35.7

                          Build 03-271301-1852-0602-00-M1-060812

                           

                          All of that looks correct and the runtime is 2.1.1.7.

                           

                          The device and scanner were purchased through a distributer so I think it is a regular production device. If it helps the s/n is 11357521400247.

                           

                          The device will raise and process the imagerEvent without problem but not the imagerCaptureEvent.  The oddest thing is that I swear it was working then stopped.

                           

                          I also captured the below from the Dalvik debugger maybe that will mean something to you?

                           

                          10-05 19:15:23.406: E/MOTO plugin(2110): writing to socket 0000000001000008JSOBJECT02000006imager03000007capture09000000

                          10-05 19:15:23.406: E/MOTO plugin(2110):

                          10-05 19:15:23.406: E/MOTO plugin(2110): wrote 62 characters

                          10-05 19:15:23.414: E/BaseCameraAdapter(1575): hardware/ti/omap3/camera-omap4/src/BaseCameraAdapter.cpp:169 enableMsgType - Message type subscription no supported yet!

                          10-05 19:15:23.859: E/AudioHardwareALSA(1575): RE-OPEN AFTER STANDBY:: took 56 msecs

                          10-05 19:15:24.078: E/OMXCameraAdapter(1575): hardware/ti/omap3/camera-omap4/src/OMXCameraAdapter/OMXCameraAdapter.cpp:2555 SignalEvent - Event queue empty!!!

                          10-05 19:15:24.078: E/OMXCapture(1575): hardware/ti/omap3/camera-omap4/src/OMXCameraAdapter/OMXCapture.cpp:861 stopImageCapture - Timeout expired on shutter callback

                          10-05 19:15:25.898: E/BaseCameraAdapter(1575): hardware/ti/omap3/camera-omap4/src/BaseCameraAdapter.cpp:223 disableMsgType - Message type 0x200 subscription no supported yet!

                          10-05 19:15:26.750: E/JavaBinder(1667): !!! FAILED BINDER TRANSACTION !!!

                          10-05 19:15:26.976: E/Omap4ALSA(1575): called drain&close

                           

                           

                           

                          I just received a VM from my Motorola contact saying that support has reproduced the issue and it has been forwarded to Engineering.

                           

                          Steve

                        • Re: ET1: Access camera from hybrid application - Is there a way?
                          Robert Galvin

                          Are your web pages running from the device or locally on the device?

                           

                          In the following code example, I set the destination to be a local file on the device. If my web pages are running locally on the device then this will probably be ok because I can reference the local file system. If my web pages are running on a web server, then I would probably want to change the destination to either be an FTP server or a HTTP web page that is ready to accept a file upload. The online help has an example showing this. Notice that I am not using the imagerCaptureEvent below. Run this and then use USB to connect to the ET1 so you can see it is capturing the image.

                           

                          function imagerEnable()
                          {
                          imager.top=400
                          imager.width=120
                          imager.height=120
                          imager.destination = 'url("file:///image.jpg")';   // ON ET1 this will save the image captured to the SD card root as image.jpg
                          imager.enable();
                          }
                          
                          function imagerCapture()
                          {
                          imager.capture();
                          }
                          

                           

                           

                          The imagerCaptureEvent was recently added so that you can handle the image in a dataURI string instead of actual files. This event is supposed to fire when the dataURI is available for the image capture. In this case, I also am seeing that this is not working on the ET1. I have an email into engineering to find out what is going on.

                           

                          The imagerEvent however fires when the image is copied to the location in the destination property above, so you can register for a callback when the file transfer is complete (in the case of HTTP Post or FTP).

                           

                          I will respond back when I get some details around the dataURI method.