Websites Navigation: Airbit | Shop | m-shell.net
Languages: EN | DE
Welcome Guest Search | Active Topics | Members | Log In | Register

cam2 example Options
airbit
Posted: Wednesday, April 07, 2010 12:12:25 PM
Rank: Administration
Groups: Administration , Member

Joined: 4/3/2008
Posts: 105
Location: Herrliberg/Switzerland
For your convenience, we post here an example how to use the new cam2 module (mShell Rel. 3.05), especially the auto focus and how to find the scale for the view finder.
Code:
/*
  Simple test of Cam2 module with focusing.
*/
use cam2, graph as g, ui, audio

// take an image to "file"
function take(file)
  if cam2.focus(null)=0 then
    // focus not supported: directly take image
    audio.beep(880, 200);
    cam2.take(file)
  else
    // start focusing
    cam2.focus(true);
    // wait 2 seconds until focusing completes
    if cam2.focus(2000) then
      audio.beep(1760, 100);
      cam2.take(file)
    else
      audio.beep(440, 800)
    end
  end
end

// turn camera on and obtain image size
s=cam2.on();
// show the graphics screen and obtain its size
g.show();
gs=g.size();
// compute scale such that preview fits
for scale in [1, 0.5, 0.25, 0.125] do
  vs=[scale*s[0], scale*s[1]];
  dx=gs[0]-vs[0]; dy=gs[1]-vs[1];
  if dx>=0 and dy>=0 then
    break
  end
end;
// show centered, scaled preview
x=dx/2; y=dy/2;
vs=cam2.view(x, y, scale);
// enable the pointer
ui.ptr(ui.relative);
ui.keys(ui.strokes);
clicked=false;
nr=0;
while true do
  // wait for pointer event
  cmd=ui.cmd();
  if isarray(cmd) then
    if cmd[2]&1#0 then
      if not clicked then
        // if clicked into the view finder, take an image
        if cmd[0]>=x and cmd[0]<x+vs[0] and
          cmd[1]>=y and cmd[1]<y+vs[1] then
          nr++;
          take("Cam2Test-" + nr + ".jpg")
        end;
        clicked=true
      end
    else
      clicked=false
    end
  elsif cmd=ui.gokey then
    nr++;
    take("Cam2Test-" + nr + ".jpg")
  end
end;
g.hide();
cam2.off()

File Attachment(s):
Cam2Test.m (2kb) downloaded 36 time(s).


SLRSOFT
Posted: Wednesday, April 07, 2010 4:04:51 PM
Rank: Advanced Member
Groups: Member

Joined: 1/20/2009
Posts: 38
Location: Turkey
Thanks Juerg.
Think


"Benim kudretimin ulaştığı yere,sizin hayalleriniz bile ulaşamaz."
Fatih Sultan Mehmet Han.
Foolx
Posted: Thursday, April 08, 2010 9:56:17 AM
Rank: Member
Groups: Member

Joined: 9/7/2009
Posts: 21
Location: Hamburg, Germany
Doesn't work here. He cant find cam2, but i already installed the newest version.
Where can cam2 be found?

thanks!
awolswat
Posted: Thursday, April 08, 2010 11:36:30 AM
Rank: Newbie
Groups: Member

Joined: 7/9/2009
Posts: 4
Location: Hong kong
Hi Foolx,

Are you already install camerawrapper.sisx?
The "airbit" source code work fine on my nokia 5800.

Awolswat
Foolx
Posted: Thursday, April 08, 2010 3:57:03 PM
Rank: Member
Groups: Member

Joined: 9/7/2009
Posts: 21
Location: Hamburg, Germany
ok, all is working now ;) My fault ;)
donatas
Posted: Thursday, April 08, 2010 9:09:35 PM
Rank: Advanced Member
Groups: Member

Joined: 6/16/2007
Posts: 187
Location: Ukraine
hm... i didn't understood, is there are way to disable autofocus?
to take pics as is?
for ex
start focusing
if focuses earlier that (x)seconds - take picture with focus
if no - take as is...
huh? :)

http://djdonatas.com
awolswat
Posted: Saturday, April 10, 2010 6:56:32 AM
Rank: Newbie
Groups: Member

Joined: 7/9/2009
Posts: 4
Location: Hong kong
Dear airbit,

Do you have a Video Recording example?
I want to make a program to take 640x480 30fps on my nokia 5800.
But, It always show error. Could you mind give me some suggestion?
Thanks a lot.

Awolswat


use video,cam2,video,ui,time,proc,app,vibra,files,audio,cam;

cam.on(-1, true);

rIndex=0; fIndex=0;
for r=0 to len(video.recorders)-1 do
formats=video.recorders[r]["formats"];
for f=0 to len(formats)-1 do
if index(formats[f]["name"], "MPEG-4")>=0 then
rIndex=r; fIndex=f
end
end
end;

// create
t=video.create("MyVideo.mp4", rIndex, fIndex);

video.setup();

video.record();

sleep(10000);
video.stop();
video.close();

cam.off()
Nyarlathotep
Posted: Saturday, April 10, 2010 1:42:05 PM
Rank: Advanced Member
Groups: Member

Joined: 10/1/2008
Posts: 38
Location: Italy
hi bro!

How do I force the use of flash??
Nick_7
Posted: Sunday, April 11, 2010 2:07:20 PM
Rank: Advanced Member
Groups: Member

Joined: 6/3/2009
Posts: 37
Location: Italy
Hi, where could I find camerawrapper.sisx?Think

ρѕρ & gт-ι8910 н∂ нα¢кє∂
showcku
Posted: Sunday, April 25, 2010 1:51:07 PM
Rank: Member
Groups: Member

Joined: 7/24/2009
Posts: 14
Location: TURKEY
thanx for works
drivett
Posted: Tuesday, July 20, 2010 3:34:55 PM
Rank: Newbie
Groups: Member

Joined: 12/27/2008
Posts: 2
Location: Russia
and what about UIQ3 phones? standart video settings/
airbit
Posted: Thursday, August 19, 2010 12:08:00 PM
Rank: Administration
Groups: Administration , Member

Joined: 4/3/2008
Posts: 105
Location: Herrliberg/Switzerland
Since there is no camera wrapper module available for UIQ3, m module cam2 is not available on that platform. Use module cam instead.
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.
This page was generated in 0.162 seconds.

mShell Home  > Forum