linux怎么关闭摄像头,Ubuntu下关闭笔记本自带摄像头

I'm on 12.04LTS. I have an external USB HD cam that I run as default (preferably). To do this, after every reboot I have to run

sudo su -c 'echo "0" > /sys/bus/usb/devices/1-1.4/bConfigurationValue'

(1-1.4 is my laptop cam) This disables my laptop cam.

Then in GUVCview I get:

Which is easily fixed by simply unplugging, and plugging the external cam's usb into port. Then my external cam works great,and is my default selection, and the only one listed in devices under GUVCview, and is marked as default in Multimedia selector.

Everytime I reboot Ubuntu, I have to go through this little process. Not a terrible problem, but is there a way to make my 1-1.4 value stay at "0" ?

EDIT:

EDIT 2:

Open Terminal

cd /etc

sudo nano rc.local

Edit File by placing command Before " Exit 0"

Press CTRL - X

Y to save

!/bin/sh -e

#

# rc.local

#

# This script is executed at the end of each multiuser runlevel.

# Make sure that the script will "exit 0" on success or any other

# value on error.

#

# In order to enable or disable this script just change the execution

# bits.

#

# By default this script does nothing.

echo "0" > /sys/bus/usb/devices/1-1.4/bConfigurationValue

exit 0

Try adding theecho "0" > /sys/bus/usb/...command you mentioned in your question to therc.localfile.

Do this by running sudo nano /etc/rc.local, and then adding the command echo "0" > /sys/bus/usb/... before the exit 0 line. You can then save it with Ctrl+O.

On using rc.local, see here. It basically runs the command on boot, so might disable the camera, on boot.

To get it to work, make it executable with chmod +x rc.local.

If you need to stop rc.local running on boot, use chmod -x rc.local. If you want to re-enable the camera without rebooting, you might be able to use echo "1" > /sys/bus/usb/... - note the 1value..

原文:http://askubuntu.com/questions/403613/disabled-my-built-in-laptop-camera-but-it-re-enables-after-reboot

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您好!对于在树莓派上使用摄像头,您可以在Ubuntu系统中进行以下步骤: 1. 确保您的树莓派已经安装了Ubuntu操作系统。如果没有安装,您可以从官方网站下载适用于树莓派的Ubuntu镜像并进行安装。 2. 连接摄像头模块到树莓派的摄像头接口。树莓派摄像头模块通常附一个有排针的扁平电缆,您只需将其插入到树莓派上的摄像头接口上即可。 3. 确保摄像头模块已经被启用。打开终端并输入以下命令: ``` sudo raspi-config ``` 在配置界面中,选择"Interfacing Options",然后选择"Camera"。在提示中选择"Yes"来启用摄像头模块。 4. 安装相机相关软件包。打开终端并输入以下命令来安装相机软件包: ``` sudo apt-get update sudo apt-get install -y python3-picamera ``` 这将安装Python3的Picamera模块,它是一个用于与树莓派摄像头进行交互的常用工具。 5. 使用Python编写代码来控制摄像头。您可以使用任何文本编辑器创建一个Python脚本,并使用Picamera模块进行摄像头操作。例如,以下是一个简单的示例: ```python from picamera import PiCamera from time import sleep camera = PiCamera() camera.start_preview() sleep(5) camera.capture('/home/pi/image.jpg') camera.stop_preview() ``` 这段代码将在摄像头预览5秒后拍摄一张照片,并将其保存到指定路径。 6. 运行Python脚本。在终端中,使用以下命令运行您的Python脚本: ``` python3 your_script.py ``` 替换"your_script.py"为您保存Python脚本的实际文件名。 这样,您就可以在树莓派上使用摄像头,并通过编写Python代码来控制它了。希望这对您有所帮助!如有任何疑问,请随时向我提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值