第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在搜索視圖中設置多個按鈕?

如何在搜索視圖中設置多個按鈕?

Go
慕哥6287543 2022-12-21 10:53:41
實際上我想制作一個操作欄,當我添加下拉菜單時,其中應該有下拉菜單、搜索選項、菜單選項和另一個圖標,搜索欄不在完整的操作欄上。當我單擊搜索圖標時,搜索視圖應該在完整的操作欄上,但只有一半被下拉菜單覆蓋這是java代碼@Override    public boolean onCreateOptionsMenu(Menu menu) {        // Inflate the menu; this adds items to the action bar if it is present.        getMenuInflater().inflate(R.menu.mainpage, menu);        getMenuInflater().inflate(R.menu.android_action_bar_spinner_menu, menu);        MenuItem item = menu.findItem(R.id.spinner);        Spinner spinner = (Spinner) MenuItemCompat.getActionView(item);        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,                R.array.dropdown, android.R.layout.simple_spinner_item);        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);        spinner.setAdapter(adapter);        // Inflate the menu; this adds items to the action bar if it is present.        getMenuInflater().inflate(R.menu.menu_search, menu);        MenuItem search_item = menu.findItem(R.id.mi_search);        SearchView searchView = (SearchView) search_item.getActionView();        searchView.setFocusable(false);        searchView.setQueryHint("Search");        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {            @Override            public boolean onQueryTextSubmit(String s) {                //clear the previous data in search arraylist if exist                Toast.makeText(MainpageActivity.this, s, Toast.LENGTH_SHORT).show();                     return false;            }            @Override            public boolean onQueryTextChange(String s) {                Toast.makeText(MainpageActivity.this, s, Toast.LENGTH_SHORT).show();                return false;            }        });        return true;    }
查看完整描述

4 回答

?
慕的地10843

TA貢獻1785條經驗 獲得超8個贊

這是從網絡攝像頭捕獲圖像的示例。這是更新的、面向對象的、整合的 OpenCV 2 Python API。


import cv2


# Camera 0 is your port number 

camera_port = 0


#Number of frames to throw away while the camera adjusts to light levels

ramp_frames = 30


# Initialize cam with port

camera = cv2.VideoCapture(camera_port)


# Captures a single image & returns  in PIL format

def get_image():


# read full image out of a VideoCapture object.

retval, im = camera.read()

return im


# Ramp the camera - these frames will be discarded and are only used to allow v4l2

for i in xrange(ramp_frames):

temp = get_image()

print("Taking image...")


# Take the actual image we want to keep

camera_capture = get_image()

file = "/home/codeplasma/test_image.png"


# correct format based on the file extension you provide. Convenient!

cv2.imwrite(file, camera_capture)


# capture object until your script exits

del(camera)


查看完整回答
反對 回復 2022-12-21
?
慕妹3146593

TA貢獻1820條經驗 獲得超9個贊

也許,您應該閱讀官方文檔。你試試這段代碼。祝你好運!


import cv2


cap = cv2.VideoCapture(0)


while(True):

    # Capture frame-by-frame

    ret, frame = cap.read()


    # Display the resulting frame

    cv2.imshow('frame',frame)

    cv2.imread('./your-dir/image.png', frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):

        break


# When everything done, release the capture

cap.release()

cv2.destroyAllWindows()


查看完整回答
反對 回復 2022-12-21
?
牛魔王的故事

TA貢獻1830條經驗 獲得超3個贊

import numpy as np

import cv2


cap = cv2.VideoCapture(0)


while(True):

     # Capture frame-by-frame

     ret, frame = cap.read()


# Our operations on the frame come here

gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)


# Display the resulting frame

cv2.imshow('frame',gray)

#this line save your image into Dir

cv2.imwrite("you dir path eg. C:\", img)

if cv2.waitKey(1) & 0xFF == ord('q'):

    break


# When everything done, release the capture

cap.release()

cv2.destroyAllWindows()


查看完整回答
反對 回復 2022-12-21
?
當年話下

TA貢獻1890條經驗 獲得超9個贊

首先嘗試像管理員一樣運行 python 的 shell/console 來執(zhí)行腳本:這段代碼應該運行良好:


import cv2 #to take photos or pre-process it with some computer vision technique

import os #to save images at any path i.g E:/myfolder/images/

import argparse #to receive parameters in the console

#Open the camera:

cam = cv2.VideoCapture(0)



ap = argparse.ArgumentParser()

ap.add_argument("-c", "--quantity", required=True, help="Set the quantity of images that you want to take p. ej. 350")

args = vars(ap.parse_args())


#set path where we are going to save the image.

outDirectory = "E:/alxor/"


def takePhoto(number):

    if cam.isOpened():

        print("Camera opened successfully!")

        #Get one image:

        ret, frame = cam.read()

        name = "image_"+str(number)+".jpg"

        print(name)

        cv2.imwrite(os.path.join(outDirectory, name), frame)

    else:

        print("[INFO] Can not open the camera :(")

c = int(args["quantity"])

j = 1

while j <= c: #introduciendo 's' salimos del bucle


    print ("[INFO] WRITE 's' TO EXIT: ")

    print ("[INFO] WRITE 'c' TO TAKE A PHOTO ")

    user_input = input() #leer entrada

    if user_input is 'c':


        takePhoto(j)

        print("[INFO] IMAGE #"+str(j)+" SAVED...")


    if user_input is 's':

        break

        print("[INFO] THE PROGRAM HAS FINISHED..")

    j+=1


#Turn off the camera..

cam.release()

print("[INFO] THE PROGRAM HAS FINISHED..")

更新 1. 使用 os 庫將圖像保存在所需路徑中。更新 2. 拍攝 n 張圖像的選項我也在 github 中留下了這段代碼: 代碼


查看完整回答
反對 回復 2022-12-21
  • 4 回答
  • 0 關注
  • 144 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號