华为P Smart 2019智能手机中的虚拟陀螺仪?

问题描述 投票:0回答:1

我有Huawei P Smart 2019智能手机。大多数有规格的网站(包括华为官方网站)都说这款机型没有陀螺仪。

consumer.huawei.com

www.gsmarena.com

www.phonearena.com

但我使用传感器融合应用程序测试了Huawei P Smart 2019。此应用程序检测陀螺仪传感器并显示其工作原理。

有什么问题?为什么即使制造商说在Huawei P Smart 2019没有陀螺仪传感器,尽管那里有一个传感器?

也许这是一个virtual gyroscope

package org.hitlabnz.sensor_fusion_demo;

import ...

public class SensorSelectionActivity extends FragmentActivity {
    SectionsPagerAdapter mSectionsPagerAdapter;
    ViewPager mViewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sensor_selection);

        mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

        mViewPager = (ViewPager) findViewById(R.id.pager);
        mViewPager.setAdapter(mSectionsPagerAdapter);

        // Check if device has a hardware gyroscope
        SensorChecker checker = new HardwareChecker((SensorManager) getSystemService(SENSOR_SERVICE));
        if(!checker.IsGyroscopeAvailable()) {

            // If a gyroscope is unavailable, display a warning
            displayHardwareMissingWarning();
        }
    }

    private void displayHardwareMissingWarning() {
        AlertDialog ad = new AlertDialog.Builder(this).create();  
        ad.setCancelable(false);   
        ad.setTitle(getResources().getString(R.string.gyroscope_missing)); 
        ad.setMessage(getResources().getString(R.string.gyroscope_missing_message));

        ad.setButton(DialogInterface.BUTTON_NEUTRAL, getResources().getString(R.string.OK), new DialogInterface.OnClickListener() {  
            @Override  
            public void onClick(DialogInterface dialog, int which) {   
                dialog.dismiss();                      
            }  
        });  
        ad.show();  
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.sensor_selection, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.action_about:
            Intent intent = new Intent(this, AboutActivity.class);
            startActivity(intent);
            return true;
        }
        return false;
    }

    public class SectionsPagerAdapter extends FragmentPagerAdapter {
        public SectionsPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            Fragment fragment = new OrientationVisualisationFragment();
            Bundle args = new Bundle();
            args.putInt(OrientationVisualisationFragment.ARG_SECTION_NUMBER, position + 1);
            fragment.setArguments(args);
            return fragment;
        }

        @Override
        public int getCount() {
            return 6;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            Locale l = Locale.getDefault();
            switch (position) {
            case 0:
                return getString(R.string.title_section1).toUpperCase(l);
            case 1:
                return getString(R.string.title_section2).toUpperCase(l);
            case 2:
                return getString(R.string.title_section3).toUpperCase(l);
            case 3:
                return getString(R.string.title_section4).toUpperCase(l);
            case 4:
                return getString(R.string.title_section5).toUpperCase(l);
            case 5:
                return getString(R.string.title_section6).toUpperCase(l);
            }
            return null;
        }
    }
}

陀螺仪可以在x,y和z轴周围完美地工作。

enter image description here

我需要一个用于ARCore的陀螺仪和加速度计。

java kotlin augmented-reality arcore gyroscope
1个回答
1
投票

关于它的工作原理的一点解释:qazxsw poi

使用智能手机上的指南针和加速度传感器,您可以制作虚拟陀螺仪。你需要从罗盘和加速器中获取数据并进行大量工作并对其进行排序,但你可以通过以下方式处理陀螺仪功能:-)

© www.soinside.com 2019 - 2024. All rights reserved.