7 Replies Latest reply on Jan 29, 2015 12:20 AM by Thierry Leloup

    Is it possible to use Camera API with free Rhodes 5.0.25 package ?

    Thierry Leloup

      Hello everybody,

       

      According to the Rhodes 5.0.25 API Summary (Rhomobile | RhoMobile API Summary) the camera module does not require a license and is usable in both RUby and Javascript.Capture d’écran 2015-01-26 à 14.42.52.png

      The asterik indicates "Some API classes that may have been available in RhoMobile Suite 2.2 and have not yet have been incorporated in the new Common API class set for RhoMobile Suite 5.0.25, here these APIs are marked with an asterisk (*). However these APIs are still available in the 2.2 format but only in Ruby."

       

      which is a first contradiction.

       

      Then, I tried to use it with my free Rhodes 5.0.25 package with a simple Ruby call and "camera" added to the Build.yml extensions :

      <li><%= 'Camera info : ' + Camera::get_camera_info('main') %></li>


      Rhosimulator : No error during the build (rake run:iphone:simulator") but a systematic error in Rhosimulator : GET http://127.0.0.1:59316/app/Demonstrator/testInfos 500 (Server error)

      Real Android or iOs device : systematic build error (rake device:android:production) :

      ext - camera

      exception: cannot load such file -- camera

      rake aborted!

      Can't find extension 'camera'. Aborting build.

       

      My question is then : is it really possible ti use the camera API with the free Rhodes 5.0.25 package or is the purchase of RhoElements (299$/month !) mandatory ?

       

      Thanks for your help,

      Thierry

       


        • Re: Is it possible to use Camera API with free Rhodes 5.0.25 package ?
          Jon Tara

          The Camera API is not yet available in Javascript. It uses the old 2.2 API style, and is only available in Ruby. It is included under the open-source license - no paid license is needed. For the Camera API, RhoElements will gain you nothing beyond what you have now. I use the Camera API in 5.0.25, and it works fine. You must use Ruby for now.

           

          Unfortunately, when the basic documentation about Ruby and Javascript APIs was written, the Camera API was used as the "poster child". But, then, it was never implemented using the new API style. Oops!

           

          I really urge all Rhodes developers to learn Ruby and use the Ruby APIs if at all possible. IMO, the Javascript API is a crutch in case you do not want to learn Ruby. It just adds an unnecessary layer of complication.

           

          As well, Ruby code runs faster on mobile platforms than Javascript does, though that may seem counter-intuitive. That said, in most cases, there is not a lot of actual Javascript code being used in the Javascript versions of APIs. The Javascript code just hands the job off to the core APIs, which are typically written in a combination of Ruby, Java (on Android), C, and C++.

           

          The code that you yourself write, will run faster if you write it in Ruby. If your code is just a bit of "glue" code, it will be of no practical consequence. If you write extensive code, it is better to do it in Ruby.

            • Re: Is it possible to use Camera API with free Rhodes 5.0.25 package ?
              Thierry Leloup

              Hello Jon,

               

              Thanks for your answer but, as I mentioned, I tried to call a simple camera API method in Ruby, which, according to you, should work, but it does not  :

                   <li><%= 'Camera info : ' + Camera::get_camera_info('main') %></li>

               

              And what is the reason of the "exception: cannot load such file -- camera" during build ? Did I forget to install something ?

               

              Here is my gems list :

              rhoconnect (5.0.0)

              rhoconnect-adapters (1.0.6)

              rhoconnect-client (5.0.2)

              rhodes (5.0.2)

              rhoelements (5.0.2)

              rhohub (1.0)

              I use RVM with a Ruby 2.1.5 version and I have added "camera" in the Build.yml extensions.

                • Re: Is it possible to use Camera API with free Rhodes 5.0.25 package ?
                  Jon Tara

                  You do not need to add camera in the build.yml extensions. The camera API is not an extension. There is no camera extension. That is why you get the error message. The file (extension) you tried to load is not there. It's not needed.

                   

                  get_camera_info() does not return a string, and so you cannot use it as you have above. It returns a Ruby hash, which contains a number of bits of information.

                   

                  This will give you a string with a printable version of the hash:

                   

                  <li><%= 'Camera info : ' + Camera::get_camera_info('main').inspect %></li>



                    • Re: Is it possible to use Camera API with free Rhodes 5.0.25 package ?
                      Thierry Leloup

                      Hi Jon,

                       

                      Thanks for your answer. I just tried what you mentionned and it works !

                       

                      FYI, I added "camera" in the extensions because that's what the documentation was indicating (see Rhomobile | Camera API):

                      Enabling the Camera

                      To use the camera API, you need to enable the camera on the device. Do this by adding that capability to the build.yml file:

                      capabilities: - camera 

                       

                      I still have 2 questions though :

                      1. I need to capture both videos and pictures using the embedded camera. As far as I understand the Camera class, it only allows to take a picture/snapshot but not a video one. Is this correct ?
                      2. I found the "mediacapture" extension (see Rhomobile | Camera) but I cannot make it work (yet) (see my other post here : Is mediacapture extension working with Rhodes 5.0.25 free version ? and on top of that, it should only support picture capture and not video capture..
                        So, my question is : is it possible to do video capture with Rhodes 5.0.25 ? if so, which extension should I use ?

                       

                      Thierry

                        • Re: Is it possible to use Camera API with free Rhodes 5.0.25 package ?
                          Jon Tara

                          "capabilities" and "extensions" are not the same thing!

                           

                          Capabilities just lists device features that your application uses. Extensions are code libraries, and may or may not implement some device feature.

                           

                          The Camera class only deals with still pictures. You can get them from either the camera directly or from the stored camera roll.

                           

                          I don't know any thing about mediacapture. I think the API documentation is pretty goofed-up for Camera. I know that the the old "2.2" API works, I think the most accurate documentation for current Camera use is in the RhoMobile Guide section on "Device Capabilities". There is a camera section there:

                           

                              Rhomobile | Camera

                           

                          As well, if you click a link to the API in the list of APIs, it will take you to the old 2.2 docs, which, in my experience, is accurate for current Rhodes 5.0.25:

                           

                          Rhomobile | Camera API

                           

                          To be sure that you got to the right documentation, make sure that the API documentation has a yellow warning at the top saying that it is old 2.2 documentation.

                           

                          I'm not sure how you even found the new documentation for code that hasn't yet been implemented. It should be reported as a documentation error. (I will do so.) Did you just see how the URL for the API documentation is formed, and then type-in "camera" yourself in the URL? I think when it was realized that the new Camera API was not ready for release, they must have kept the documentation, since it was already written, and just made sure (or TRIED to make sure) that there were no links leading to it...

                           

                          For clarification, (or confusion, thanks to Forum formatting of URLs...) I'm referring to this. As far as I know, this is not yet actually implemented. IMO it should not be present in the documentation, but is:

                           

                          Rhomobile | Camera

                           

                          (yea, it looks here on the forum just like the first link above, but it is not the same thing...)

                          ----

                          I don't know anything about any plans for video capture in Rhodes, unless I missed something. (But I haven't been looking, LOL.) It's not something I've tried with Rhodes. But I know this: you can write your own native extension to do anything that the device is capable of.

                           

                          It really is something probably best done in native code. (e.g. Objective-C, C, C++, Java, depending on device.) I'm just basing this on my own past experience with video capture. (I've written a capture driver for an accessory device for notebooks, and I've written software for video capture and analysis for sports - specifically, golf).

                           

                          Specifically, what is it that you need to do with video? Just capture it? Capture and display while capturing? A native extension might do the job, or else a native UI extension, or both.

                            • Re: Is it possible to use Camera API with free Rhodes 5.0.25 package ?
                              Thierry Leloup

                              Hi Jon,

                               

                              First of all, thanks for your complete and clear answer. I really appreciate !

                               

                              Concerning the "capabilities" vs "extensions" comment, shame on me. I really am a Rhodes' rooky.

                               

                              Concerning the mediacapture doc page, honnestly I don't remember how I ended on this page. I think I ggogled something like "picture capture rhodes" or something...

                               

                              Concerning the camera capability (see, I learn fast ;-)), I tried the Camera::get_camera_info call on an iOs device and it is working alright. But when I tried it on two different android devices, it does not work correctly, ie it returns 320x240 pixels for both main and front camera although the main camera resolution is 8 M pixels and front camera is 5 M pixels...

                              Any idea about this problem ?

                               

                              And finally, about the video capture : in fact, we are evaluating Rhodes for a cross platform appilcation we want to develop and we need, amongst other functions, to capture videos, ie capture/display in real time and on top of that have a videoconference function between two applications as well. For the videoconference function, I will try to integrate WebRTC into our Rhodes app...

                               

                              Thierry