Jump to content


Front Camera on CM6 / CM7

- - - - -

33 replies to this topic

#1
dr.flo

dr.flo

    Diehard

  • Members
  • PipPipPipPip
  • 429 posts
To access the front camera instead of back camera, one could do something like this:


cd /dev/msm_camera
mv msm_camera0 back_cam
mv msm_camera1 front_cam

# to select back cam by default...
ln -s back_cam msm_camera0

# or to select front cam
ln -s front_cam msm_camera0


edit:

Now here is the script to do it. Install it via CWM and you will have a new shell command "camswitch" in /system/bin.
Tested on CM6 only. Might as well work on CM7.

Can be executed in terminal emulator (su required) or via adb.

The easiest version of executing it is using GScript Lite (-> market). Just add the script once like this:
Attached File  gscript.png   15.18K   65 downloads

Then you'll be able to create a shortcut to it on the home screen...

Edited by dr.flo, 17 February 2012 - 09:48 PM.


#2
pier11

pier11

    Addict

  • Members
  • PipPipPipPipPip
  • 883 posts
  • Gender:Male
  • Location:New York, USA
  • Devices:T-Mobile Pulse U8220
do you know by a chance if CyanogenMod's Camera app works with front cam of ANY phone in existence?


#3
dr.flo

dr.flo

    Diehard

  • Members
  • PipPipPipPip
  • 429 posts

View Postpier11, on 26 January 2012 - 02:25 PM, said:

do you know by a chance if CyanogenMod's Camera app works with front cam of ANY phone in existence?

The problem is not the camera app. The problem is that native support for multiple cameras was first added in gingerbread. That means in eclair and froyo, when a device had multiple cameras, some vendor specific custom way is used to switch cameras.

There is a function inside libcameraservice (compiled from source) that  returns the number of available cameras. This can be modified to return 2  for the pulse. Then the CM7 camera app offers a switch camera button.  But is is not functional because we do not know what vendor specific function to call inside our libcamera (telling it to open /dev/msm_camera/msm_camera1) .

If you do not know how to tell the libs they should use camera 1 instead  of camera 0 - then the only way to make them use camera 1 is to rename  its device into camera 0

For CM6, as this is froyo, there is no way. It simply has no api to select which camera. But the rename trick would work. If I do it, I can record video and take pics from front cam.


#4
dr.flo

dr.flo

    Diehard

  • Members
  • PipPipPipPip
  • 429 posts
For CM7:

this is what I meant in libcameraservice;
You can see that for HTC devices, the vendor specific way of switching cameras in known. Therefore fore these devices, both cameras are supported in CM7.

#ifdef BOARD_USE_FROYO_LIBCAMERA
static int getNumberOfCameras()
{
	if (access(HTC_SWITCH_CAMERA_FILE_PATH, W_OK) == 0) 
	{		
		return 2;	
	}	/* FIXME: Support non-HTC front camera */   

	return 1;
}

#endif




#if defined(BOARD_USE_FROYO_LIBCAMERA) || defined(BOARD_HAVE_HTC_FFC)
#define HTC_SWITCH_CAMERA_FILE_PATH "/sys/android_camera2/htcwc"
static void htcCameraSwitch(int cameraId){
	char buffer[16];	
	int fd;
	if (access(HTC_SWITCH_CAMERA_FILE_PATH, W_OK) == 0)
	{		
		snprintf(buffer, sizeof(buffer), "%d", cameraId);
		fd = open(HTC_SWITCH_CAMERA_FILE_PATH, O_WRONLY);		
   	write(fd, buffer, strlen(buffer));		
  	close(fd);	
 	}
}
#endif


#5
pier11

pier11

    Addict

  • Members
  • PipPipPipPipPip
  • 883 posts
  • Gender:Male
  • Location:New York, USA
  • Devices:T-Mobile Pulse U8220
thinking is something similar to "/sys/android_camera2/htcwc" in our proprietary libs...


#6
dr.flo

dr.flo

    Diehard

  • Members
  • PipPipPipPip
  • 429 posts

View Postpier11, on 26 January 2012 - 03:39 PM, said:

thinking is something similar to "/sys/android_camera2/htcwc" in our proprietary libs...

thats what we have to find. then we'll have native support for both cams in CM7.

A quick strings libcamera.so showed that it is not /sys/android_camera2/... - the problem is there are plenty of ways this could have possibly be done. Maybe we have to analyze the stock eclair camera.apk? I've never looked at an apk. Is there java inside? In source form maybe?


#7
D-D-

D-D-

    Diehard

  • Members
  • PipPipPipPip
  • 407 posts
  • Gender:Male
  • Devices:T-mobile Pulse
  • Twitter:@boriseto
You need to extact the apk and decompile (kinda) the classes. Ive done that with some launchers so I could tweak them a little.


#8
pier11

pier11

    Addict

  • Members
  • PipPipPipPipPip
  • 883 posts
  • Gender:Male
  • Location:New York, USA
  • Devices:T-Mobile Pulse U8220

View Postdr.flo, on 26 January 2012 - 03:51 PM, said:

thats what we have to find. then we'll have native support for both cams in CM7.

A quick strings libcamera.so showed that it is not /sys/android_camera2/... - the problem is there are plenty of ways this could have possibly be done. Maybe we have to analyze the stock eclair camera.apk? I've never looked at an apk. Is there java inside? In source form maybe?
yes, it can be decompiled to semi-human-readable (hackable) language - smali. Then can be assembled back.
apk-tool if I recollect correctly does the trick
I guess author of the tool tweaks g maps this way

Edited by pier11, 26 January 2012 - 04:10 PM.


#9
dr.flo

dr.flo

    Diehard

  • Members
  • PipPipPipPip
  • 429 posts
updated first post :D


#10
felip3

felip3

    Newbie

  • Members
  • Pip
  • 11 posts
  • Devices:huawei u8220
this is a great fix, finally i can see my front camera working.

btw im using the txg rom and i cant switch off  the auto focus from the camera app, i can record video with the front camera though. there is a way for me to include the switch in resolution and quality in the script so it can be done automatically? i dont have too much experience in android but at least i could research if im pointed in the right way.


GREAT WORK DUDE

Edited by felip3, 18 February 2012 - 12:31 AM.


#11
twrock

twrock

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 1,588 posts
  • Location:Taiwan
  • Devices:CHT8000 (Huawei U8220)
This is really weird, but Gscript Lite isn't showing in my Market using dr.flo's CM6. Can someone upload the apk? Thanks.
Nevermind. I found it elsewhere. Still, I'm curious about why I couldn't see it on the Market.

Confirmed, works perfectly as expected, both pictures and video. Thanks.

Edited by twrock, 18 February 2012 - 01:53 AM.

Want a quicker answer?
  • Use the search function in the right hand column to search this forum or a particular thread.
  • Click on this link to go to "The Ultimate Pulse Owners Guide" and find your answer there.
  • Rom installation problems? Try this link.
(If you aren't willing to do any of that, don't be surprised if you receive a "harsh" answer from someone.)

#12
pier11

pier11

    Addict

  • Members
  • PipPipPipPipPip
  • 883 posts
  • Gender:Male
  • Location:New York, USA
  • Devices:T-Mobile Pulse U8220

View Posttwrock, on 18 February 2012 - 01:10 AM, said:

This is really weird, but Gscript Lite isn't showing in my Market using dr.flo's CM6. Can someone upload the apk? Thanks.
Nevermind. I found it elsewhere. Still, I'm curious about why I couldn't see it on the Market.

strange, shows up on the Market with um840 rom. But I might have less restrictions due to geo location...


#13
twrock

twrock

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 1,588 posts
  • Location:Taiwan
  • Devices:CHT8000 (Huawei U8220)

View Postfelip3, on 17 February 2012 - 11:40 PM, said:

this is a great fix, finally i can see my front camera working.

btw im using the txg rom and i cant switch off  the auto focus from the camera app, i can record video with the front camera though. there is a way for me to include the switch in resolution and quality in the script so it can be done automatically? i dont have too much experience in android but at least i could research if im pointed in the right way.


GREAT WORK DUDE

My guess about the inability to switch focus mode is related to all of the hacking necessary to get the camera working in Tom G's CM6 port. I'm testing dr.flo's CM6.1 Stable rom at the moment, and the camera in that rom works as expected.

So if you can wait a little while, I believe I will have an update to TXG (or a new rom mod similar to TXG) based on dr.flo's CM6. But I will not promise it will be available today. ;) At the moment I'm having some trouble with the initial setup upon first boot after flashing the rom. I'd like to make the rom as noob friendly as possible, and setup problems need to be corrected first.

Edit: Sorry, don't hold me to that promise. Things have turned out to be more complicated than I anticipated. I've had multiple problems, many more than I anticipated, and I'm not having positive results trying to build the full rom. If you want, you can just go through that thread and do all the the steps to install it in parts.

Edited by twrock, 19 February 2012 - 12:06 PM.

Want a quicker answer?
  • Use the search function in the right hand column to search this forum or a particular thread.
  • Click on this link to go to "The Ultimate Pulse Owners Guide" and find your answer there.
  • Rom installation problems? Try this link.
(If you aren't willing to do any of that, don't be surprised if you receive a "harsh" answer from someone.)

#14
twrock

twrock

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 1,588 posts
  • Location:Taiwan
  • Devices:CHT8000 (Huawei U8220)

View Postpier11, on 18 February 2012 - 01:50 AM, said:

strange, shows up on the Market with um840 rom. But I might have less restrictions due to geo location...

It might also have been a location problem for me. Google and Taiwan are still fighting over access to the Android Market, because the Taiwan government passed a law that all internet sales had to come with a 14 day return policy. The Market has a 15 minute return policy, so Google turned off paid apps for us. But I think it also sometimes affects other things not showing up. Usually I can work around all of that, but sometimes not.

Want a quicker answer?
  • Use the search function in the right hand column to search this forum or a particular thread.
  • Click on this link to go to "The Ultimate Pulse Owners Guide" and find your answer there.
  • Rom installation problems? Try this link.
(If you aren't willing to do any of that, don't be surprised if you receive a "harsh" answer from someone.)

#15
dr.flo

dr.flo

    Diehard

  • Members
  • PipPipPipPip
  • 429 posts
it showed up in market for me (cm6-clean first aka branch froyo version, but that shouldn't matter).


#16
desalesouche

desalesouche

    Diehard

  • Members
  • PipPipPipPip
  • 471 posts
  • Gender:Male
  • Devices:u8230/u8860

View Postdr.flo, on 26 January 2012 - 01:58 PM, said:

To access the front camera instead of back camera, one could do something like this:


cd /dev/msm_camera
mv msm_camera0 back_cam
mv msm_camera1 front_cam

# to select back cam by default...
ln -s back_cam msm_camera0

# or to select front cam
ln -s front_cam msm_camera0


edit:

Now here is the script to do it. Install it via CWM and you will have a new shell command "camswitch" in /system/bin.
Tested on CM6 only. Might as well work on CM7.

Can be executed in terminal emulator (su required) or via adb.

The easiest version of executing it is using GScript Lite (-> market). Just add the script once like this:
Attachment gscript.png

Then you'll be able to create a shortcut to it on the home screen...

it works on cm7  i can see front camera working but i can²t take picture..how do i turn off autofocus in cm7?

edit ihave been in camera parameters   and both option about focus are off...
so what sould i replace as files to make it work on cm7?     thx

edit2  would it be possible with that script to have video call  working on cm6 clean?

Edited by desalesouche, 19 February 2012 - 06:28 PM.


#17
dr.flo

dr.flo

    Diehard

  • Members
  • PipPipPipPip
  • 429 posts

View Postdesalesouche, on 19 February 2012 - 01:38 PM, said:

edit2  would it be possible with that script to have video call  working on cm6 clean?
Try it. Should work.

As for the questions regarding cm7 - I currently don't run that rom. I don't know which options the camera app has there. On cm6, I select "normal" as focus mode. And don't forget QVGA picture resolution.
But all this should not be needed for video calling applications as it affects picture mode only.


#18
felip3

felip3

    Newbie

  • Members
  • Pip
  • 11 posts
  • Devices:huawei u8220
just want to tell everyone that if you install camera 360 you can use this trick in any rom, the app has te ability to disable the focus. im using the front camera in cm7 with camera 360, (i couldnt use it with the stock camera app)


#19
desalesouche

desalesouche

    Diehard

  • Members
  • PipPipPipPip
  • 471 posts
  • Gender:Male
  • Devices:u8230/u8860

View Postfelip3, on 24 February 2012 - 04:26 PM, said:

just want to tell everyone that if you install camera 360 you can use this trick in any rom, the app has te ability to disable the focus. im using the front camera in cm7 with camera 360, (i couldnt use it with the stock camera app)
can you make videocall /visio with cm7?


#20
felip3

felip3

    Newbie

  • Members
  • Pip
  • 11 posts
  • Devices:huawei u8220

View Postdesalesouche, on 24 February 2012 - 06:22 PM, said:

can you make videocall /visio with cm7?

i can record videos with the front camera for sure, i will download skype or something and try videocalling and post if it works, i think there wont be problems at all.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users