This commit is contained in:
parent
a721bcdd39
commit
b33875167d
|
|
@ -0,0 +1,3 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.9 (3)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredPackages">
|
||||
<value>
|
||||
<list size="5">
|
||||
<item index="0" class="java.lang.String" itemvalue="pandas" />
|
||||
<item index="1" class="java.lang.String" itemvalue="matplotlib" />
|
||||
<item index="2" class="java.lang.String" itemvalue="numpy" />
|
||||
<item index="3" class="java.lang.String" itemvalue="basics" />
|
||||
<item index="4" class="java.lang.String" itemvalue="cv2" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<option name="ignoredErrors">
|
||||
<list>
|
||||
<option value="E501" />
|
||||
<option value="E262" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<option name="ignoredErrors">
|
||||
<list>
|
||||
<option value="N803" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyStatementEffectInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="PyStubPackagesAdvertiser" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredPackages">
|
||||
<list>
|
||||
<option value="PyQt5-stubs==5.15.6.0" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (3)" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/Identikit-Robot.iml" filepath="$PROJECT_DIR$/.idea/Identikit-Robot.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 61ba3d9339fffa90b55086315c93cbbbbb22b7d4
|
||||
|
|
@ -0,0 +1,236 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="BranchesTreeState">
|
||||
<expand>
|
||||
<path>
|
||||
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
<item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="3b0d5ef2-6301-45ac-b9be-73a17800d1e1" name="Default Changelist" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/.idea/.gitignore" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/Identikit-Robot.iml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/profiles_settings.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/get_head.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/haarcascade_frontalface_default.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/img.jpg" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/test" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/test.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="Python Script" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectId" id="2WtQ9d3jW2CaYzd1wkVhiAep3yM" />
|
||||
<component name="ProjectLevelVcsManager">
|
||||
<ConfirmationsSetting value="2" id="Add" />
|
||||
</component>
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
|
||||
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
||||
<property name="com.intellij.ide.scratch.LRUPopupBuilder$1/New Scratch File" value="Python" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
|
||||
</component>
|
||||
<component name="RunManager" selected="Python.main">
|
||||
<configuration name="get_head" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="Identikit-Robot" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/get_head.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="get_visage" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="Identikit-Robot" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$APPLICATION_CONFIG_DIR$/scratches" />
|
||||
<option name="IS_MODULE_SDK" value="false" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$APPLICATION_CONFIG_DIR$/scratches/get_visage.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="Identikit-Robot" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="test" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="Identikit-Robot" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Python.main" />
|
||||
<item itemvalue="Python.get_head" />
|
||||
<item itemvalue="Python.test" />
|
||||
<item itemvalue="Python.get_visage" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="3b0d5ef2-6301-45ac-b9be-73a17800d1e1" name="Default Changelist" comment="" />
|
||||
<created>1697549245784</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1697549245784</updated>
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
<option name="TAB_STATES">
|
||||
<map>
|
||||
<entry key="MAIN">
|
||||
<value>
|
||||
<State />
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
<option name="oldMeFiltersMigrated" value="true" />
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
||||
</component>
|
||||
<component name="WindowStateProjectService">
|
||||
<state x="543" y="210" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1699896592711">
|
||||
<screen x="0" y="0" width="1536" height="816" />
|
||||
</state>
|
||||
<state x="543" y="210" key="#com.intellij.fileTypes.FileTypeChooser/0.0.1536.816@0.0.1536.816" timestamp="1699896592711" />
|
||||
<state x="596" y="253" key="FileChooserDialogImpl" timestamp="1697549719587">
|
||||
<screen x="0" y="0" width="1536" height="816" />
|
||||
</state>
|
||||
<state x="596" y="253" key="FileChooserDialogImpl/0.0.1536.816@0.0.1536.816" timestamp="1697549719587" />
|
||||
<state width="1515" height="162" key="GridCell.Tab.0.bottom" timestamp="1700052760623">
|
||||
<screen x="0" y="0" width="1536" height="816" />
|
||||
</state>
|
||||
<state width="1515" height="162" key="GridCell.Tab.0.bottom/0.0.1536.816@0.0.1536.816" timestamp="1700052760623" />
|
||||
<state width="1515" height="162" key="GridCell.Tab.0.center" timestamp="1700052760623">
|
||||
<screen x="0" y="0" width="1536" height="816" />
|
||||
</state>
|
||||
<state width="1515" height="162" key="GridCell.Tab.0.center/0.0.1536.816@0.0.1536.816" timestamp="1700052760623" />
|
||||
<state width="1515" height="162" key="GridCell.Tab.0.left" timestamp="1700052760623">
|
||||
<screen x="0" y="0" width="1536" height="816" />
|
||||
</state>
|
||||
<state width="1515" height="162" key="GridCell.Tab.0.left/0.0.1536.816@0.0.1536.816" timestamp="1700052760623" />
|
||||
<state width="1515" height="162" key="GridCell.Tab.0.right" timestamp="1700052760623">
|
||||
<screen x="0" y="0" width="1536" height="816" />
|
||||
</state>
|
||||
<state width="1515" height="162" key="GridCell.Tab.0.right/0.0.1536.816@0.0.1536.816" timestamp="1700052760623" />
|
||||
<state width="1493" height="258" key="GridCell.Tab.1.bottom" timestamp="1698034237886">
|
||||
<screen x="0" y="0" width="1536" height="816" />
|
||||
</state>
|
||||
<state width="1493" height="258" key="GridCell.Tab.1.bottom/0.0.1536.816@0.0.1536.816" timestamp="1698034237886" />
|
||||
<state width="1493" height="258" key="GridCell.Tab.1.center" timestamp="1698034237886">
|
||||
<screen x="0" y="0" width="1536" height="816" />
|
||||
</state>
|
||||
<state width="1493" height="258" key="GridCell.Tab.1.center/0.0.1536.816@0.0.1536.816" timestamp="1698034237886" />
|
||||
<state width="1493" height="258" key="GridCell.Tab.1.left" timestamp="1698034237886">
|
||||
<screen x="0" y="0" width="1536" height="816" />
|
||||
</state>
|
||||
<state width="1493" height="258" key="GridCell.Tab.1.left/0.0.1536.816@0.0.1536.816" timestamp="1698034237886" />
|
||||
<state width="1493" height="258" key="GridCell.Tab.1.right" timestamp="1698034237886">
|
||||
<screen x="0" y="0" width="1536" height="816" />
|
||||
</state>
|
||||
<state width="1493" height="258" key="GridCell.Tab.1.right/0.0.1536.816@0.0.1536.816" timestamp="1698034237886" />
|
||||
<state x="277" y="53" key="SettingsEditor" timestamp="1697549721753">
|
||||
<screen x="0" y="0" width="1536" height="816" />
|
||||
</state>
|
||||
<state x="277" y="53" key="SettingsEditor/0.0.1536.816@0.0.1536.816" timestamp="1697549721753" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
import cv2
|
||||
import numpy as np
|
||||
|
||||
# Démarrez la capture vidéo depuis la webcam
|
||||
|
||||
|
||||
def get_image():
|
||||
cap = cv2.VideoCapture(0)
|
||||
count = 0
|
||||
condition = False
|
||||
while condition == False:
|
||||
ret, frame = cap.read()
|
||||
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
||||
blurred = cv2.GaussianBlur(gray, (3, 3), 0)
|
||||
height, width = blurred.shape
|
||||
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
|
||||
faces = face_cascade.detectMultiScale(blurred, scaleFactor=1.3, minNeighbors=5, minSize=(30, 30))
|
||||
|
||||
color_cicle = (0, 0, 255)
|
||||
for (x, y, w, h) in faces:
|
||||
if (x + w // 2 ) - int(width / 2) <= 10 and (x + w // 2 ) - int(width / 2) >= -10:
|
||||
if (y + h // 2) - int(height / 2) <= 10 and (y + h // 2) - int(height / 2) >= -10:
|
||||
if (w + h)//4 >= 140 and (w + h)//4 <= 160:
|
||||
color_cicle = (0, 255, 0)
|
||||
count += 1
|
||||
else:
|
||||
count = 0
|
||||
else:
|
||||
count = 0
|
||||
else:
|
||||
count = 0
|
||||
|
||||
if count == 5:
|
||||
print("take picture here")
|
||||
image = gray
|
||||
condition = True
|
||||
return image
|
||||
cv2.circle(frame, (x + w // 2, y + h // 2), (w + h) // 4, color_cicle, 5)
|
||||
cv2.circle(frame, (int(width / 2), int(height / 2)), 150, (255, 255, 255), 2)
|
||||
|
||||
cv2.imshow('Head Detection', frame)
|
||||
if cv2.waitKey(1) & 0xFF == ord('q'):
|
||||
break
|
||||
|
||||
cap.release()
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,15 @@
|
|||
import cv2
|
||||
|
||||
import get_head
|
||||
|
||||
gray = get_head.get_image()
|
||||
|
||||
cv2.imshow('Grey Image', gray)
|
||||
|
||||
edges = cv2.Canny(gray, 10, 100)
|
||||
cv2.imshow('Image avec Contours de Visage', edges)
|
||||
|
||||
cv2.waitKey(0)
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
#include <ros/ros.h>
|
||||
#include <std_msgs/String.h>
|
||||
|
||||
void ChatterCallback()
|
||||
{
|
||||
ROS_INFO("I heard : [%s]", msg.data.c_str());
|
||||
}
|
||||
|
||||
int main( int argc, char **argv)
|
||||
{
|
||||
ros::init(argc, argv, "subcriber");
|
||||
ros::NodeHandle nh;
|
||||
ros::Subsciber subscriber=nh.subscribe("chatter", 1, ChatterCallback);
|
||||
ros::spin();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#include <ros/ros.h>
|
||||
#include <std_msgs/String.h>
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
ros::init(argc, argv, "Publisher");
|
||||
ros::NodeHandle nh;
|
||||
ros::Publisher publisher = nh.advertise<std_msgs::String>("chatter",1);
|
||||
ros::Rate loopRate(10);
|
||||
while(ros::ok())
|
||||
{
|
||||
std_msgs::String message;
|
||||
message.data = "hello world" + std::to_string(count);
|
||||
ROS_INFO_STREAM(message.data);
|
||||
publisher.publish(message);
|
||||
ros::spinOnce();
|
||||
loopRate.sleep();
|
||||
count==;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <ros/ros.h>
|
||||
#include <std_msgs/String.h>
|
||||
|
||||
void ChatterCallback()
|
||||
{
|
||||
ROS_INFO("I heard [%s]"+msg.data.c_str());
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ros::init(argc, argv, "Subscriber");
|
||||
ros::NodeHandle nh;
|
||||
ros::Subsctiber subscriber = nh.subscribe("chatter", 10, ChatterCallback);
|
||||
ros::spin();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#include <ros/ros.h>
|
||||
#include <std_msgs/String.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ros::init(argc, argv, "publisher");
|
||||
ros::NodeHandle nh;
|
||||
ros::Punlisher publisher = nh.advretise<std_msgs::String>("chatter", 1);
|
||||
ros::Rate loopRate(10);
|
||||
while(ros::ok()){
|
||||
std_msgs::String message;
|
||||
message.data = "Hello World"+std::to_string(count);
|
||||
ROS_INFO_STREAM(message.data);
|
||||
chatter_Publisher.publish(message);
|
||||
ros::spinOnce;
|
||||
loopRate.sleep();
|
||||
count++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#inclulde <ros/ros.h>
|
||||
#include <std_msgs/String.h>
|
||||
|
||||
void ChatterCallback()
|
||||
{
|
||||
ROS_INFO("I hear [%s]"std_msg.data.c_str());
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ros::init(argc, argv, "listener/subscriber";
|
||||
ros::NodeHandle nh;
|
||||
ros::Subscriber subscriber = nh.subscribe("chatter", 10, ChatterCallback);
|
||||
ros::spin;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <ros/ros.h>
|
||||
#include <std_msgs/String.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ros::init(argc, argv, "talker/publisher";
|
||||
ros::NodeHandle nh;
|
||||
ros::Publisher publisher = nh.advertise<std_msgs::String>("chatter",1);
|
||||
ros::Rate loopRate(10);
|
||||
while(ros::ok())
|
||||
{
|
||||
std_msgs::String message;
|
||||
message.data = "Hello World "+std::to_string(count);
|
||||
ROS_INFO_STREAM(message.data);
|
||||
Chatter_Publisher.publish(message);
|
||||
ros::spinOnce();
|
||||
loopRate.sleep();
|
||||
count++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
import cv2
|
||||
import dlib
|
||||
import numpy as np
|
||||
from imutils import face_utils
|
||||
from deeplabv3 import DeepLabV3
|
||||
|
||||
# Load face detector model from Dlib
|
||||
detector = dlib.get_frontal_face_detector()
|
||||
|
||||
# Load DeepLabV3 model for hair segmentation
|
||||
deeplab_model = DeepLabV3(weights='pascal_voc', input_shape=(None, None, 3))
|
||||
|
||||
# Load the input image
|
||||
image_path = "img.jpg"
|
||||
image = cv2.imread(image_path)
|
||||
original_image = image.copy()
|
||||
|
||||
# Convert image to RGB (DeepLabV3 model requires RGB format)
|
||||
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
||||
|
||||
# Detect face using Dlib
|
||||
faces = detector(image_rgb)
|
||||
for face in faces:
|
||||
(x, y, w, h) = face_utils.rect_to_bb(face)
|
||||
cv2.rectangle(image, (x, y), (x + w, y + h), (255, 0, 0), 2)
|
||||
|
||||
# Perform hair segmentation using DeepLabV3
|
||||
face_roi = original_image[y:y + h, x:x + w]
|
||||
resized_face_roi = cv2.resize(face_roi, (512, 512)) # Resize for DeepLabV3 model input size
|
||||
hair_mask = deeplab_model.predict(resized_face_roi)
|
||||
hair_mask = (hair_mask.squeeze() == 15).astype(np.uint8) * 255 # Hair class in Pascal VOC dataset is 15
|
||||
|
||||
# Apply hair mask to the original image
|
||||
hair_segmented = cv2.bitwise_and(face_roi, face_roi, mask=hair_mask)
|
||||
|
||||
# Replace hair in the original image with the segmented hair
|
||||
original_image[y:y + h, x:x + w] = cv2.bitwise_and(original_image[y:y + h, x:x + w], original_image[y:y + h, x:x + w], mask=cv2.bitwise_not(hair_mask))
|
||||
original_image[y:y + h, x:x + w] += hair_segmented
|
||||
|
||||
# Save the segmented image
|
||||
cv2.imwrite("segmented_face_and_hair.jpg", original_image)
|
||||
|
||||
# Display the segmented image
|
||||
cv2.imshow("Segmented Face and Hair", original_image)
|
||||
cv2.waitKey(0)
|
||||
cv2.destroyAllWindows()
|
||||
Loading…
Reference in New Issue